本文整理汇总了Python中mkt.set_user函数的典型用法代码示例。如果您正苦于以下问题:Python set_user函数的具体用法?Python set_user怎么用?Python set_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.addon = Webapp.objects.get(pk=337141)
self.dest = os.path.join(settings.TMP_PATH, 'preview')
self.user = UserProfile.objects.get(pk=999)
mkt.set_user(self.user)
if not os.path.exists(self.dest):
os.makedirs(self.dest)
示例2: test_rejected
def test_rejected(self):
comments = "oh no you di'nt!!"
mkt.set_user(UserProfile.objects.get(email='[email protected]'))
mkt.log(mkt.LOG.REJECT_VERSION, self.webapp,
self.webapp.current_version, user_id=999,
details={'comments': comments, 'reviewtype': 'pending'})
self.webapp.update(status=mkt.STATUS_REJECTED)
make_rated(self.webapp)
(self.webapp.versions.latest()
.all_files[0].update(status=mkt.STATUS_REJECTED))
r = self.client.get(self.url)
eq_(r.status_code, 200)
doc = pq(r.content)('#version-status')
eq_(doc('.status-rejected').length, 1)
eq_(doc('#rejection').length, 1)
eq_(doc('#rejection blockquote').text(), comments)
my_reply = 'fixed just for u, brah'
r = self.client.post(self.url, {'notes': my_reply,
'resubmit-app': ''})
self.assert3xx(r, self.url, 302)
webapp = self.get_webapp()
eq_(webapp.status, mkt.STATUS_PENDING,
'Reapplied apps should get marked as pending')
eq_(webapp.versions.latest().all_files[0].status, mkt.STATUS_PENDING,
'Files for reapplied apps should get marked as pending')
action = mkt.LOG.WEBAPP_RESUBMIT
assert AppLog.objects.filter(
addon=webapp, activity_log__action=action.id).exists(), (
"Didn't find `%s` action in logs." % action.short)
示例3: test_rereview_flag_adult
def test_rereview_flag_adult(self):
mkt.set_user(user_factory())
app = app_factory()
app.set_content_ratings({
mkt.ratingsbodies.ESRB: mkt.ratingsbodies.ESRB_E,
mkt.ratingsbodies.CLASSIND: mkt.ratingsbodies.CLASSIND_18,
})
_flag_rereview_adult(app, mkt.ratingsbodies.ESRB,
mkt.ratingsbodies.ESRB_T)
assert not app.rereviewqueue_set.count()
assert not ActivityLog.objects.filter(
action=mkt.LOG.CONTENT_RATING_TO_ADULT.id).exists()
# Adult should get flagged to rereview.
_flag_rereview_adult(app, mkt.ratingsbodies.ESRB,
mkt.ratingsbodies.ESRB_A)
eq_(app.rereviewqueue_set.count(), 1)
eq_(ActivityLog.objects.filter(
action=mkt.LOG.CONTENT_RATING_TO_ADULT.id).count(), 1)
# Test things same same if rating stays the same as adult.
app.set_content_ratings({
mkt.ratingsbodies.ESRB: mkt.ratingsbodies.ESRB_A,
})
_flag_rereview_adult(app, mkt.ratingsbodies.ESRB,
mkt.ratingsbodies.ESRB_A)
eq_(app.rereviewqueue_set.count(), 1)
eq_(ActivityLog.objects.filter(
action=mkt.LOG.CONTENT_RATING_TO_ADULT.id).count(), 1)
示例4: wrapper
def wrapper(*args, **kw):
old_user = get_user()
set_user(get_task_user())
try:
result = f(*args, **kw)
finally:
set_user(old_user)
return result
示例5: process_request
def process_request(self, request):
"""Attach authentication/permission helpers to request."""
request.check_ownership = partial(acl.check_ownership, request)
# figure out our list of groups...
if request.user.is_authenticated():
mkt.set_user(request.user)
request.groups = request.user.groups.all()
示例6: setUp
def setUp(self):
self.user = user_factory(email="porkbelly")
mkt.set_user(self.user)
self.profile = self.user
self.addon = Webapp.objects.get()
self.version = self.addon.latest_version
self.thread = self._thread_factory()
self.note = self._note_factory(self.thread)
self.attachment1, self.attachment2 = self._attachments(self.note)
示例7: test_set_task_user
def test_set_task_user(self):
@set_task_user
def some_func():
return get_user()
set_user(UserProfile.objects.get(email='[email protected]'))
eq_(get_user().pk, 999)
eq_(some_func().pk, int(settings.TASK_USER_ID))
eq_(get_user().pk, 999)
示例8: test_comm_thread_after_resubmission
def test_comm_thread_after_resubmission(self):
self.webapp.update(status=mkt.STATUS_REJECTED)
make_rated(self.webapp)
mkt.set_user(UserProfile.objects.get(email='[email protected]'))
(self.webapp.versions.latest()
.all_files[0].update(status=mkt.STATUS_REJECTED))
my_reply = 'no give up'
self.client.post(self.url, {'notes': my_reply,
'resubmit-app': ''})
notes = CommunicationNote.objects.all()
eq_(notes.count(), 1)
eq_(notes[0].body, my_reply)
示例9: test_processing
def test_processing(self):
"""
The mock client always returns the same data. Set up the app so it
matches the submission ID and verify the data is saved as expected.
"""
mkt.set_user(user_factory())
app = app_factory()
IARCInfo.objects.create(webapp=app, submission_id=52,
security_code='FZ32CU8')
app.set_descriptors([
'has_classind_violence',
'has_esrb_strong_lang',
'has_pegi_language', 'has_pegi_online',
'has_usk_lang',
])
app.set_interactives([])
app.set_content_ratings({
mkt.ratingsbodies.CLASSIND: mkt.ratingsbodies.CLASSIND_L
})
process_iarc_changes()
app = app.reload()
# Check ratings. CLASSIND should get updated.
cr = app.content_ratings.get(
ratings_body=mkt.ratingsbodies.CLASSIND.id)
eq_(cr.rating, mkt.ratingsbodies.CLASSIND_14.id)
cr = app.content_ratings.get(ratings_body=mkt.ratingsbodies.ESRB.id)
eq_(cr.rating, mkt.ratingsbodies.ESRB_M.id)
assert ActivityLog.objects.filter(
action=mkt.LOG.CONTENT_RATING_CHANGED.id).count()
# Check descriptors.
rd = RatingDescriptors.objects.get(webapp=app)
self.assertSetEqual(rd.to_keys(), [
'has_esrb_strong_lang',
'has_classind_lang',
'has_pegi_lang', 'has_pegi_online',
'has_usk_lang',
])
# Check interactives.
ri = RatingInteractives.objects.get(webapp=app)
self.assertSetEqual(ri.to_keys(), [
'has_shares_info', 'has_shares_location', 'has_digital_purchases',
'has_users_interact'
])
示例10: test_rejected_packaged
def test_rejected_packaged(self):
self.webapp.update(is_packaged=True)
comments = "oh no you di'nt!!"
mkt.set_user(UserProfile.objects.get(email='[email protected]'))
mkt.log(mkt.LOG.REJECT_VERSION, self.webapp,
self.webapp.current_version, user_id=999,
details={'comments': comments, 'reviewtype': 'pending'})
self.webapp.update(status=mkt.STATUS_REJECTED)
(self.webapp.versions.latest()
.all_files[0].update(status=mkt.STATUS_REJECTED))
r = self.client.get(self.url)
eq_(r.status_code, 200)
doc = pq(r.content)('#version-status')
eq_(doc('.status-rejected').length, 1)
eq_(doc('#rejection').length, 1)
eq_(doc('#rejection blockquote').text(), comments)
示例11: setUp
def setUp(self):
super(TestAccountListForm, self).setUp()
self.addon = Webapp.objects.get(pk=337141)
self.addon.update(status=mkt.STATUS_NULL,
highest_status=mkt.STATUS_PUBLIC)
self.provider = get_provider(name='bango')
self.price = Price.objects.filter()[0]
AddonPremium.objects.create(addon=self.addon, price=self.price)
self.user = UserProfile.objects.get(pk=31337)
mkt.set_user(self.user)
self.other = UserProfile.objects.get(pk=999)
self.admin = UserProfile.objects.get(email='[email protected]')
self.kwargs = {
'addon': self.addon,
'provider': self.provider,
}
示例12: _post_teardown
def _post_teardown(self):
mkt.set_user(None)
clean_translations(None) # Make sure queued translations are removed.
super(TestCase, self)._post_teardown()
示例13: setUp
def setUp(self):
now = datetime.now()
bom = datetime(now.year, now.month, 1)
self.lm = bom - timedelta(days=1)
self.user = UserProfile.objects.filter()[0]
mkt.set_user(self.user)
示例14: process_response
def process_response(self, request, response):
mkt.set_user(None)
return response
示例15: setUp
def setUp(self):
mkt.set_user(UserProfile.objects.all()[0])
self.form = forms.AppFeaturesForm()
self.app = Webapp.objects.get(pk=337141)
self.features = self.app.current_version.features