本文整理汇总了Python中users.tests.group函数的典型用法代码示例。如果您正苦于以下问题:Python group函数的具体用法?Python group怎么用?Python group使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了group函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_new_contributor
def test_new_contributor(self, get_current):
"""Verify that interested contributors are added to group."""
get_current.return_value.domain = 'su.mo.com'
group_name = 'Registered as contributor'
group(name=group_name, save=True)
data = {
'username': 'newbie',
'email': '[email protected]',
'password': 'foobar22',
'password2': 'foobar22',
'interested': 'yes'}
response = self.client.post(reverse('users.register', locale='en-US'),
data, follow=True)
eq_(200, response.status_code)
u = User.objects.get(username='newbie')
eq_(group_name, u.groups.all()[0].name)
# Activate user and verify email is sent.
key = RegistrationProfile.objects.all()[0].activation_key
url = reverse('users.activate', args=[u.id, key])
response = self.client.get(url, follow=True)
eq_(200, response.status_code)
eq_(2, len(mail.outbox))
assert mail.outbox[1].subject.find('Welcome to') == 0
assert u.username in mail.outbox[1].body
示例2: test_right_group_profile
def test_right_group_profile(self):
"""Make sure we get the right group profile."""
g1 = group(pk=100)
g1.save()
eq_(100, g1.pk)
g2 = group(pk=101)
g2.save()
eq_(101, g2.pk)
p = GroupProfile.objects.create(pk=100, group=g2, slug='foo')
eq_(100, p.pk)
eq_(group_link(g1), g1.name)
示例3: test_new_contributor
def test_new_contributor(self, get_current):
"""Verify that interested contributors are added to group."""
get_current.return_value.domain = 'su.mo.com'
group_name = 'Registered as contributor'
group(name=group_name, save=True)
data = {
'username': 'newbie',
'email': '[email protected]',
'password': 'foobar22',
'password2': 'foobar22',
'interested': 'yes'}
response = self.client.post(reverse('users.register', locale='en-US'),
data, follow=True)
eq_(200, response.status_code)
u = User.objects.get(username='newbie')
eq_(group_name, u.groups.all()[0].name)
示例4: test_delete_post_belongs_to_thread_and_forum
def test_delete_post_belongs_to_thread_and_forum(self):
"""
Delete post action - post belongs to thread and thread belongs to
forum.
"""
f = forum(save=True)
t = thread(forum=f, save=True)
# Post belongs to a different forum and thread.
p = forum_post(save=True)
u = p.author
# Give the user the permission to delete posts.
g = group(save=True)
ct = ContentType.objects.get_for_model(f)
permission(codename='forums_forum.post_delete_forum',
content_type=ct, object_id=p.thread.forum_id, group=g,
save=True)
permission(codename='forums_forum.post_delete_forum',
content_type=ct, object_id=f.id, group=g, save=True)
g.user_set.add(u)
self.client.login(username=u.username, password='testpass')
# Post isn't in the passed forum:
r = get(self.client, 'forums.delete_post',
args=[f.slug, p.thread.id, p.id])
eq_(404, r.status_code)
# Post isn't in the passed thread:
r = get(self.client, 'forums.delete_post',
args=[p.thread.forum.slug, t.id, p.id])
eq_(404, r.status_code)
示例5: setUp
def setUp(self):
super(AnnouncementModelTests, self).setUp()
self.creator = user(save=True)
profile(user=self.creator)
self.group = group(save=True)
self.locale = locale(locale='es', save=True)
self.creator.groups.add(self.group)
示例6: 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')
示例7: setUp
def setUp(self):
url = reverse('forums.threads', args=[u'test-forum'])
self.context = {'request': test_utils.RequestFactory().get(url)}
self.group = group(save=True)
# Set up forum_1
f = self.forum_1 = forum(save=True)
ct = ContentType.objects.get_for_model(self.forum_1)
permission(codename='forums_forum.thread_edit_forum', content_type=ct,
object_id=f.id, group=self.group, save=True)
permission(codename='forums_forum.post_edit_forum', content_type=ct,
object_id=f.id, group=self.group, save=True)
permission(codename='forums_forum.post_delete_forum', content_type=ct,
object_id=f.id, group=self.group, save=True)
permission(codename='forums_forum.thread_delete_forum',
content_type=ct, object_id=f.id, group=self.group,
save=True)
permission(codename='forums_forum.thread_sticky_forum',
content_type=ct, object_id=f.id, group=self.group,
save=True)
permission(codename='forums_forum.thread_move_forum', content_type=ct,
object_id=f.id, group=self.group, save=True)
# Set up forum_2
f = self.forum_2 = forum(save=True)
permission(codename='forums_forum.thread_move_forum', content_type=ct,
object_id=f.id, group=self.group, save=True)
示例8: test_group_link_with_profile
def test_group_link_with_profile(self):
g = group()
g.save()
p = GroupProfile.objects.create(group=g, slug='foo')
text = group_link(g)
doc = pq(text)
eq_(reverse('groups.profile', args=[p.slug]),
doc('a')[0].attrib['href'])
eq_(g.name, doc('a')[0].text)
示例9: test_group_avatar
def test_group_avatar(self):
g = group()
g.save()
p = GroupProfile.objects.create(group=g, slug='foo')
url = group_avatar(p)
eq_(settings.DEFAULT_AVATAR, url)
p.avatar = Mock()
p.avatar.url = '/foo/bar'
url = group_avatar(p)
eq_('/foo/bar', url)
示例10: test_personal_dashboards
def test_personal_dashboards(self):
"""Just run through it to make sure there aren't obvious explosions."""
g = group(name='winners', save=True)
g2 = group(name='losers', save=True)
u = user(save=True)
u.groups.add(g)
u.groups.add(g2)
GroupDashboard.objects.create(group=g, dashboard='sea', parameters='1')
GroupDashboard.objects.create(group=g2, dashboard='sea',
parameters='3')
class MockRequest(object):
user = u
request = MockRequest()
dashes = personal_dashboards(request)
# Sort order of the two ATestDashboards is by group name.
eq_(2, len(dashes))
eq_('3', dashes[0].parameters)
eq_(g, dashes[1].group)
示例11: test_ga_custom_variable_on_admin_login
def test_ga_custom_variable_on_admin_login(self):
"""After logging in, there should be a ga-push data attr on body."""
user_ = profile().user
# Add user to Administrators and so should be "Contributor - Admin":
user_.groups.add(group(name="Administrators", save=True))
response = self.client.post(
reverse("users.login"), {"username": user_.username, "password": "testpass"}, follow=True
)
eq_(200, response.status_code)
doc = pq(response.content)
assert '"Contributor - Admin"' in doc("body").attr("data-ga-push")
示例12: setUp
def setUp(self):
super(HelpfulVotesGraphTests, self).setUp()
self.user = user(save=True)
self.client.login(username=self.user.username, password='testpass')
self.group = group(name='Contributors', save=True)
# Without this, there were unrelated failures with l10n dashboard
self.REDIS_KEY = settings.HELPFULVOTES_UNHELPFUL_KEY
try:
self.redis = redis_client('helpfulvotes')
self.redis.flushdb()
except RedisError:
raise SkipTest
示例13: test_ga_custom_variable_on_contributor_login
def test_ga_custom_variable_on_contributor_login(self):
"""After logging in, there should be a ga-push data attr on body."""
user_ = profile().user
# Add user to Contributors and so should be "Contributor":
user_.groups.add(group(name='Contributors', save=True))
response = self.client.post(reverse('users.login'),
{'username': user_.username,
'password': 'testpass'},
follow=True)
eq_(200, response.status_code)
doc = pq(response.content)
assert '"Contributor"' in doc('body').attr('data-ga-push')
示例14: _setup_announcement
def _setup_announcement(self, visible_dates=True):
g = group(save=True)
u1 = user(save=True)
u2 = user(save=True)
u1.groups.add(g)
u2.groups.add(g)
# Create profiles for these users
profile(user=u1)
profile(user=u2)
self.user = u2
return announcement(creator=u1, group=g, save=True,
visible_dates=visible_dates)
示例15: test_edit_thread_moderator
def test_edit_thread_moderator(self):
"""Editing post as a moderator works."""
t = forum_post(save=True).thread
f = t.forum
u = user(save=True)
g = group(save=True)
ct = ContentType.objects.get_for_model(f)
permission(codename='forums_forum.thread_edit_forum', content_type=ct,
object_id=f.id, group=g, save=True)
g.user_set.add(u)
self.client.login(username=u.username, password='testpass')
r = post(self.client, 'forums.edit_thread',
{'title': 'new title'}, args=[f.slug, t.id])
eq_(200, r.status_code)
edited_t = Thread.uncached.get(id=t.id)
eq_('new title', edited_t.title)