本文整理汇总了Python中users.tests.user函数的典型用法代码示例。如果您正苦于以下问题:Python user函数的具体用法?Python user怎么用?Python user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self, switch_is_active):
switch_is_active.return_value = True
super(KarmaAPITests, self).setUp()
try:
self.mgr = KarmaManager()
redis_client('karma').flushdb()
except RedisError:
raise SkipTest
self.user1 = user(save=True)
self.user2 = user(save=True)
self.user3 = user(save=True)
TestAction1(user=self.user1).save()
TestAction2(user=self.user2).save()
TestAction2(user=self.user2).save()
TestAction1(user=self.user3).save()
TestAction1(user=self.user3).save()
TestAction1(user=self.user3).save()
self.mgr.update_top()
self.client.login(username=self.user1.username, password='testpass')
add_permission(self.user1, models.Title, 'view_dashboard')
示例2: setUp
def setUp(self):
super(AddRemoveLeaderTests, self).setUp()
self.locale = locale(locale='es', save=True)
self.user = user(save=True)
add_permission(self.user, Locale, 'change_locale')
self.leader = user(save=True)
self.client.login(username=self.user.username, password='testpass')
示例3: test_active_answerers
def test_active_answerers(self):
"""Test active answerers API call."""
# A user with 10 answers
u1 = user(save=True)
for x in range(10):
answer(save=True, creator=u1)
# A user with 9 answers
u2 = user(save=True)
for x in range(9):
answer(save=True, creator=u2)
# A user with 1 answer
u3 = user(save=True)
answer(save=True, creator=u3)
# There should be only one active contributor.
url = reverse('api_dispatch_list',
kwargs={'resource_name': 'kpi_active_answerers',
'api_name': 'v1'})
response = self.client.get(url + '?format=json')
eq_(200, response.status_code)
r = json.loads(response.content)
eq_(r['objects'][0]['contributors'], 1)
示例4: test_for_user_not_in_group
def test_for_user_not_in_group(self):
"""Checks the locale dashboard doesn't load for user not in group."""
user(username='test', save=True)
self.client.login(username='test', password='testpass')
response = self.client.get(reverse('dashboards.group',
args=[self.g.pk], locale='en-US'))
eq_(404, response.status_code)
示例5: setUp
def setUp(self):
super(AddRemoveLeaderTests, self).setUp()
self.user = user(save=True)
add_permission(self.user, GroupProfile, 'change_groupprofile')
self.leader = user(save=True)
self.group_profile = group_profile(group=group(save=True), save=True)
self.client.login(username=self.user.username, password='testpass')
示例6: test_sorting_creator
def test_sorting_creator(self):
"""Sorting threads by creator."""
thread(creator=user(username='aaa', save=True), save=True)
thread(creator=user(username='bbb', save=True), save=True)
threads = sort_threads(Thread.objects, 3, 1)
self.assert_(threads[0].creator.username >=
threads[1].creator.username)
示例7: test_active_contributors
def test_active_contributors(self):
"""Test active contributors API call."""
# 2 en-US revisions by 2 contributors:
r1 = revision(creator=user(save=True), save=True)
r2 = revision(creator=user(save=True), save=True)
# A translation with 2 contributors (translator + reviewer):
d = document(parent=r1.document, locale='es', save=True)
revision(document=d, reviewed=datetime.now(),
reviewer=r1.creator, creator=r2.creator, save=True)
# 1 active support forum contributor:
# A user with 10 answers
u1 = user(save=True)
for x in range(10):
answer(save=True, creator=u1)
# A user with 9 answers
u2 = user(save=True)
for x in range(9):
answer(save=True, creator=u2)
# A user with 1 answer
u3 = user(save=True)
answer(save=True, creator=u3)
# An AoA reply (1 contributor):
reply(save=True)
r = self._get_api_result('kpi_active_contributors')
eq_(r['objects'][0]['en_us'], 2)
eq_(r['objects'][0]['non_en_us'], 2)
eq_(r['objects'][0]['support_forum'], 1)
eq_(r['objects'][0]['aoa'], 1)
示例8: test_watch_both_then_new_post
def test_watch_both_then_new_post(self, get_current):
"""Watching both forum and thread.
Replying to a thread should send ONE email."""
get_current.return_value.domain = 'testserver'
t = thread(save=True)
f = t.forum
forum_post(thread=t, save=True)
poster = user(save=True)
watcher = user(save=True)
self._toggle_watch_forum_as(f, watcher, turn_on=True)
self._toggle_watch_thread_as(t, watcher, turn_on=True)
self.client.login(username=poster.username, password='testpass')
post(self.client, 'forums.reply', {'content': 'a post'},
args=[f.slug, t.id])
eq_(1, len(mail.outbox))
p = Post.objects.all().order_by('-id')[0]
attrs_eq(mail.outbox[0], to=[watcher.email],
subject='Re: {f} - {t}'.format(f=f, t=t))
body = REPLY_EMAIL.format(
username=poster.username,
forum_slug=f.slug,
thread_title=t.title,
thread_id=t.id,
post_id=p.id)
starts_with(mail.outbox[0].body, body)
示例9: setUp
def setUp(self, switch_is_active):
switch_is_active.return_value = True
super(KarmaManagerTests, self).setUp()
try:
self.mgr = KarmaManager()
redis_client('karma').flushdb()
except RedisError:
raise SkipTest
self.user1 = user(save=True)
self.user2 = user(save=True)
self.user3 = user(save=True)
today = date.today()
# user1 actions (3 + 3 + 7):
TestAction1(user=self.user1, day=today).save()
TestAction1(user=self.user1, day=today).save()
TestAction2(user=self.user1, day=today).save()
# user2 actions (3 + 7 + 7):
TestAction1(user=self.user2, day=today - timedelta(days=8)).save()
TestAction2(user=self.user2, day=today - timedelta(days=32)).save()
TestAction2(user=self.user2, day=today - timedelta(days=360)).save()
# user3 actions (3 + 3 + 3 + 7):
TestAction1(user=self.user3, day=today - timedelta(days=10)).save()
TestAction1(user=self.user3, day=today - timedelta(days=40)).save()
TestAction1(user=self.user3, day=today - timedelta(days=190)).save()
TestAction2(user=self.user3, day=today - timedelta(days=3)).save()
示例10: setUp
def setUp(self):
super(AddRemoveContributorTests, self).setUp()
self.user = user(save=True)
self.contributor = user(save=True)
add_permission(self.user, Document, 'change_document')
self.client.login(username=self.user.username, password='testpass')
self.revision = revision(save=True)
self.document = self.revision.document
示例11: test_sorting_creator
def test_sorting_creator(self):
"""Sorting threads by creator."""
u1 = user(username='foo', save=True)
u2 = user(username='bar', save=True)
thread(creator=u1, save=True)
thread(creator=u2, save=True)
threads = sort_threads(Thread.objects, 3, 1)
self.assertEqual(threads[0].creator.username, u1.username)
self.assertEqual(threads[1].creator.username, u2.username)
示例12: setUp
def setUp(self):
# create active and inactive users
self.active_user = user(save=True,
username='activeuser',
is_active=True)
self.inactive_user = user(save=True,
username='inactiveuser',
is_active=False)
示例13: setUp
def setUp(self):
super(ThreadPermissionsTests, self).setUp()
self.doc = document(save=True)
self.u = user(save=True)
self.thread = thread(document=self.doc, creator=self.u, save=True)
self.post = self.thread.new_post(creator=self.thread.creator,
content='foo')
# Login for testing 403s
u2 = user(save=True)
self.client.login(username=u2.username, password='testpass')
示例14: test_two_approved_revision
def test_two_approved_revision(self):
u1 = user(save=True)
r1 = revision(save=True, is_approved=True, creator=u1)
d = r1.document
u2 = user(save=True)
revision(save=True, is_approved=True, creator=u2, document=d)
d.contributors.clear()
_init_contributors()
assert u1 in d.contributors.all()
assert u2 in d.contributors.all()
示例15: setUp
def setUp(self):
super(FlaggedQueueTestCase, self).setUp()
q = question(creator=user(save=True), save=True)
self.answer = answer(question=q,
creator=user(save=True),
save=True)
self.flagger = user(save=True)
u = user(save=True)
add_permission(u, FlaggedObject, 'can_moderate')
self.client.login(username=u.username, password='testpass')