本文整理汇总了Python中mozillians.users.tests.UserFactory类的典型用法代码示例。如果您正苦于以下问题:Python UserFactory类的具体用法?Python UserFactory怎么用?Python UserFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: invalidate_group_pending_terms
def invalidate_group_pending_terms(self, mail_task):
"""Invalidate a group where a user has not yet accepted the terms.
Type is indifferent for this test.
"""
member = UserFactory.create(vouched=True)
curator = UserFactory.create(vouched=True)
group = GroupFactory.create(name='Foo', invalidation_days=5)
group.curators.add(curator.userprofile)
group.add_member(curator.userprofile)
GroupMembership.objects.create(userprofile=member.userprofile, group=group,
status=GroupMembership.PENDING_TERMS,
updated_on=datetime.now() - timedelta(days=10))
curator_membership = group.groupmembership_set.filter(userprofile=curator.userprofile)
curator_membership.update(updated_on=datetime.now() - timedelta(days=10))
eq_(curator_membership[0].status, GroupMembership.MEMBER)
invalidate_group_membership()
ok_(group.groupmembership_set.filter(userprofile=member.userprofile,
status=GroupMembership.PENDING_TERMS).exists())
ok_(group.groupmembership_set.filter(userprofile=curator.userprofile).exists())
ok_(not mail_task.called)
开发者ID:akatsoulas,项目名称:mozillians,代码行数:26,代码来源:test_tasks.py
示例2: test_send_renewal_notification_inviters_email
def test_send_renewal_notification_inviters_email(self, mock_now, mock_send_mail):
"""Test renewal notification functionality for curators"""
curator1 = UserFactory.create(email='[email protected]')
curator2 = UserFactory.create(email='[email protected]')
curator3 = UserFactory.create(email='[email protected]')
member = UserFactory.create(userprofile={'full_name': 'Example Name'})
group = GroupFactory.create(name='foobar', invalidation_days=365,
accepting_new_members=Group.CLOSED)
group.curators.add(curator1.userprofile)
group.curators.add(curator2.userprofile)
group.curators.add(curator3.userprofile)
group.add_member(member.userprofile)
InviteFactory.create(inviter=curator3.userprofile, redeemer=member.userprofile,
group=group)
datetime_now = now() + timedelta(days=351)
mock_now.return_value = datetime_now
notify_membership_renewal()
ok_(mock_send_mail.called)
eq_(2, len(mock_send_mail.mock_calls))
# Check email for inviter
name, args, kwargs = mock_send_mail.mock_calls[1]
subject, body, from_addr, to_list = args
eq_(subject, '[Mozillians][foobar] Membership of "Example Name" is about to expire')
eq_(from_addr, settings.FROM_NOREPLY)
eq_(list(to_list), [u'[email protected]'])
开发者ID:akatsoulas,项目名称:mozillians,代码行数:31,代码来源:test_tasks.py
示例3: invalidate_closed_group
def invalidate_closed_group(self, mail_task):
member = UserFactory.create(vouched=True)
curator = UserFactory.create(vouched=True)
group = GroupFactory.create(name='Foo', invalidation_days=5,
accepting_new_members=Group.CLOSED)
group.curators.add(curator.userprofile)
group.add_member(curator.userprofile)
group.add_member(member.userprofile)
membership = group.groupmembership_set.filter(userprofile=member.userprofile)
curator_membership = group.groupmembership_set.filter(userprofile=curator.userprofile)
membership.update(updated_on=datetime.now() - timedelta(days=10))
curator_membership.update(updated_on=datetime.now() - timedelta(days=10))
eq_(membership[0].status, GroupMembership.MEMBER)
eq_(curator_membership[0].status, GroupMembership.MEMBER)
invalidate_group_membership()
ok_(group.groupmembership_set.filter(userprofile=member.userprofile,
status=GroupMembership.PENDING).exists())
ok_(group.groupmembership_set.filter(userprofile=curator.userprofile).exists())
mail_task.delay.assert_called_once_with(group.id, member.id, GroupMembership.MEMBER,
GroupMembership.PENDING)
开发者ID:akatsoulas,项目名称:mozillians,代码行数:26,代码来源:test_tasks.py
示例4: test_list_mozillians_in_location_region_n_city_vouched
def test_list_mozillians_in_location_region_n_city_vouched(self):
user_listed = UserFactory.create(userprofile={'is_vouched': True,
'country': 'it',
'region': 'Florence',
'city': 'madova'})
UserFactory.create(userprofile={'is_vouched': True,
'country': 'it',
'region': 'florence',
'city': 'foo'})
UserFactory.create(userprofile={'is_vouched': True})
UserFactory.create()
UserFactory.create(userprofile={'country': 'gr'})
user = UserFactory.create(userprofile={'is_vouched': True})
with self.login(user) as client:
url = reverse('phonebook:list_region_city', kwargs={'country': 'it',
'region': 'florence',
'city': 'Madova'})
response = client.get(url, follow=True)
eq_(response.status_code, 200)
self.assertTemplateUsed(response, 'phonebook/location-list.html')
eq_(response.context['country_name'], 'Italy')
eq_(response.context['city_name'], 'Madova')
eq_(response.context['region_name'], 'florence')
eq_(response.context['people'].count(), 1)
eq_(response.context['people'][0], user_listed.userprofile)
开发者ID:NightFury13,项目名称:mozillians,代码行数:25,代码来源:test_views.py
示例5: test_voucher_set_null_on_user_delete
def test_voucher_set_null_on_user_delete(self):
voucher = UserFactory.create()
vouchee = UserFactory.create(vouched=False)
vouchee.userprofile.vouch(voucher.userprofile)
voucher.delete()
vouch = Vouch.objects.get(vouchee=vouchee)
eq_(vouch.voucher, None)
开发者ID:royshouvik,项目名称:mozillians,代码行数:7,代码来源:test_models.py
示例6: test_email_now_vouched_with_voucher
def test_email_now_vouched_with_voucher(self, send_mail_mock):
voucher = UserFactory.create()
user = UserFactory.create(vouched=False)
user.userprofile._email_now_vouched(voucher.userprofile)
ok_(send_mail_mock.called)
eq_(send_mail_mock.call_args[0][3], [user.email])
ok_(voucher.userprofile.full_name in send_mail_mock.call_args[0][1])
开发者ID:royshouvik,项目名称:mozillians,代码行数:7,代码来源:test_models.py
示例7: test_voucher_nonpublic
def test_voucher_nonpublic(self):
voucher = UserFactory.create()
user = UserFactory.create(userprofile={"is_vouched": True, "vouched_by": voucher.userprofile})
user_profile = user.userprofile
user_profile.set_instance_privacy_level(PUBLIC)
eq_(user_profile.vouched_by, None)
开发者ID:J0WI,项目名称:mozillians,代码行数:7,代码来源:test_models.py
示例8: setUp
def setUp(self):
voucher = UserFactory.create(userprofile={'is_vouched': True})
self.user = UserFactory.create(
userprofile={'is_vouched': True,
'vouched_by': voucher.userprofile})
group = GroupFactory.create()
self.user.userprofile.groups.add(group)
skill = SkillFactory.create()
self.user.userprofile.skills.add(skill)
language = LanguageFactory.create()
self.user.userprofile.languages.add(language)
self.resource_url = reverse(
'api_dispatch_list',
kwargs={'api_name': 'v1', 'resource_name': 'users'})
self.mozilla_app = APIAppFactory.create(
owner=self.user, is_mozilla_app=True)
self.mozilla_resource_url = urlparams(
self.resource_url, app_name=self.mozilla_app.name,
app_key=self.mozilla_app.key)
self.community_app = APIAppFactory.create(
owner=self.user, is_mozilla_app=False)
self.community_resource_url = urlparams(
self.resource_url, app_name=self.community_app.name,
app_key=self.community_app.key)
开发者ID:TheGallery,项目名称:mozillians,代码行数:25,代码来源:test_api.py
示例9: test_vouched
def test_vouched(self):
vouched_user = UserFactory.create()
UserFactory.create(vouched=False)
UserFactory.create(userprofile={'full_name': ''})
queryset = UserProfile.objects.vouched()
eq_(queryset.count(), 1)
eq_(queryset[0], vouched_user.userprofile)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:7,代码来源:test_managers.py
示例10: test_invalidate_open_group
def test_invalidate_open_group(self, mail_task):
member = UserFactory.create(vouched=True)
curator = UserFactory.create(vouched=True)
# Group of type Group.OPEN
group = GroupFactory.create(name='Foo', terms='Example terms.', invalidation_days=5,
accepting_new_members=Group.OPEN)
group.curators.add(curator.userprofile)
group.add_member(member.userprofile)
group.add_member(curator.userprofile)
membership = group.groupmembership_set.filter(userprofile=member.userprofile)
curator_membership = group.groupmembership_set.filter(userprofile=curator.userprofile)
membership.update(updated_on=datetime.now() - timedelta(days=10))
curator_membership.update(updated_on=datetime.now() - timedelta(days=10))
eq_(membership[0].status, GroupMembership.MEMBER)
eq_(curator_membership[0].status, GroupMembership.MEMBER)
invalidate_group_membership()
ok_(not group.groupmembership_set.filter(userprofile=member.userprofile).exists())
ok_(group.groupmembership_set.filter(userprofile=curator.userprofile).exists())
mail_task.delay.assert_called_once_with(group.id, member.id, GroupMembership.MEMBER, None)
开发者ID:akatsoulas,项目名称:mozillians,代码行数:25,代码来源:test_tasks.py
示例11: setUp
def setUp(self):
voucher = UserFactory.create()
self.user = UserFactory.create(
userprofile={'is_vouched': True,
'vouched_by': voucher.userprofile})
group = GroupFactory.create()
group.add_member(self.user.userprofile)
skill = SkillFactory.create()
self.user.userprofile.skills.add(skill)
self.user.userprofile.externalaccount_set.create(type=ExternalAccount.TYPE_SUMO,
identifier='Apitest')
self.resource_url = reverse(
'api_dispatch_list',
kwargs={'api_name': 'v1', 'resource_name': 'users'})
self.mozilla_app = APIAppFactory.create(
owner=self.user, is_mozilla_app=True)
self.mozilla_resource_url = urlparams(
self.resource_url, app_name=self.mozilla_app.name,
app_key=self.mozilla_app.key)
self.community_app = APIAppFactory.create(
owner=self.user, is_mozilla_app=False)
self.community_resource_url = urlparams(
self.resource_url, app_name=self.community_app.name,
app_key=self.community_app.key)
开发者ID:birajkarmakar,项目名称:mozillians,代码行数:25,代码来源:test_api.py
示例12: test_list_mozillians_in_location_region_vouched
def test_list_mozillians_in_location_region_vouched(self):
country = CountryFactory.create()
country2 = CountryFactory.create()
region = RegionFactory.create(country=country)
region2 = RegionFactory.create(country=country)
user_listed = UserFactory.create(
userprofile={'geo_country': country,
'geo_region': region})
UserFactory.create(
userprofile={'geo_country': country,
'geo_region': region2})
UserFactory.create()
UserFactory.create(vouched=False)
UserFactory.create(vouched=False, userprofile={'geo_country': country2})
user = UserFactory.create()
with self.login(user) as client:
url = reverse(
'phonebook:list_region',
kwargs={'country': country.name, 'region': region.name})
response = client.get(url, follow=True)
eq_(response.status_code, 200)
self.assertTemplateUsed(response, 'phonebook/location_list.html')
eq_(response.context['country_name'], country.name)
eq_(response.context['city_name'], None)
eq_(response.context['region_name'], region.name)
eq_(response.context['people'].paginator.count, 1)
eq_(response.context['people'].object_list[0], user_listed.userprofile)
开发者ID:ariestiyansyah,项目名称:mozillians,代码行数:27,代码来源:test_views_list.py
示例13: test_sending_pending_email_already_sent
def test_sending_pending_email_already_sent(self):
# If a curated group has a pending membership, but it was added before the
# last time a reminder email was sent, do not send the curator an email.
# curated group:
group = GroupFactory.create()
group.curators.add(UserFactory.create().userprofile)
# Pending membership
user1 = UserFactory.create()
group.add_member(user1.userprofile, GroupMembership.PENDING)
membership = GroupMembership.objects.get(userprofile=user1.userprofile, group=group)
membership.save()
# Send email. This should update the field remembering the max pending request pk.
tasks.send_pending_membership_emails()
# Non-pending membership
user2 = UserFactory.create()
group.add_member(user2.userprofile, GroupMembership.MEMBER)
# None of this should trigger an email send
with patch('mozillians.groups.tasks.send_mail', autospec=True) as mock_send_mail:
tasks.send_pending_membership_emails()
ok_(not mock_send_mail.called)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:25,代码来源:test_tasks.py
示例14: test_email_in_identity_belongs_to_other_user
def test_email_in_identity_belongs_to_other_user(self, jws_mock, request_post_mock,
msg_mock):
"""Test adding a stronger identity and changing the primary email."""
UserFactory.create(email='[email protected]')
user1 = UserFactory.create(email='[email protected]')
(jws_mock.from_compact.return_value).payload = json.dumps({
'email': '[email protected]',
'email_verified': True,
'sub': 'ad|ldap'
})
post_json_mock = Mock()
post_json_mock.json.return_value = {
'id_token': 'id_token'
}
with self.login(user1) as client:
session = client.session
session['oidc_verify_nonce'] = 'nonce'
session['oidc_verify_state'] = 'state'
session.save()
response = client.get(self.url, self.get_data, follow=True)
msg = 'The email in this identity is used by another user.'
msg_mock.error.assert_called_once_with(ANY, msg)
with override_script_prefix('/en-US/'):
url = reverse('phonebook:profile_edit')
self.assertRedirects(response, url)
开发者ID:johngian,项目名称:mozillians,代码行数:26,代码来源:test_identities.py
示例15: test_invalidate_group_accepts_all
def test_invalidate_group_accepts_all(self, mock_send_mail):
member = UserFactory.create(vouched=True)
curator = UserFactory.create(vouched=True)
group = GroupFactory.create(name='Foo', invalidation_days=5)
group.curators.add(curator.userprofile)
group.add_member(curator.userprofile)
group.add_member(member.userprofile)
membership = group.groupmembership_set.filter(userprofile=member.userprofile)
curator_membership = group.groupmembership_set.filter(userprofile=curator.userprofile)
membership.update(updated_on=datetime.now() - timedelta(days=10))
curator_membership.update(updated_on=datetime.now() - timedelta(days=10))
eq_(membership[0].status, GroupMembership.MEMBER)
eq_(curator_membership[0].status, GroupMembership.MEMBER)
invalidate_group_membership()
ok_(not group.groupmembership_set.filter(userprofile=member.userprofile).exists())
ok_(group.groupmembership_set.filter(userprofile=curator.userprofile).exists())
subject = 'Removed from Mozillians group "foo"'
mock_send_mail.assert_called_once_with(subject, ANY, '[email protected]',
[member.email], fail_silently=False)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:25,代码来源:test_tasks.py
示例16: test_clean_email_invalid
def test_clean_email_invalid(self):
UserFactory.create(email='[email protected]')
user = UserFactory.create(email='[email protected]')
form = UserProfileAdminForm(None, instance=user.userprofile)
form.cleaned_data = {'email': '[email protected]'}
with self.assertRaises(ValidationError):
form.clean_email()
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:7,代码来源:test_admin.py
示例17: test_clean_username_invalid
def test_clean_username_invalid(self):
UserFactory.create(username='bar')
user = UserFactory.create(username='foo')
form = UserProfileAdminForm(None, instance=user.userprofile)
form.cleaned_data = {'username': 'bar'}
with self.assertRaises(ValidationError):
form.clean_username()
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:7,代码来源:test_admin.py
示例18: test_filter_all
def test_filter_all(self):
"""If they specify no filters, they get all the members"""
# Make user 1 the group curator so they can see requests
self.group.curators.add(self.user_1.userprofile)
self.group.accepting_new_members = 'by_request'
self.group.save()
# Make user 2 a full member
self.group.add_member(self.user_2.userprofile, GroupMembership.MEMBER)
member_membership = self.group.groupmembership_set.get(userprofile__user=self.user_2)
# Make user 3 a pending member
self.user_3 = UserFactory.create()
self.group.add_member(self.user_3.userprofile, GroupMembership.PENDING)
pending_membership = self.group.groupmembership_set.get(userprofile__user=self.user_3)
# Make user 4 a pending_terms member
self.user_4 = UserFactory.create()
self.group.add_member(self.user_4.userprofile, GroupMembership.PENDING_TERMS)
pending_terms_membership = self.group.groupmembership_set.get(
userprofile__user=self.user_4)
url = urlparams(self.url, filtr='all')
with self.login(self.user_1) as client:
response = client.get(url, follow=True)
people = response.context['people'].object_list
ok_(member_membership in people)
ok_(pending_membership in people)
ok_(pending_terms_membership in people)
开发者ID:akatsoulas,项目名称:mozillians,代码行数:28,代码来源:test_show.py
示例19: test_get_functional_areas
def test_get_functional_areas(self):
GroupFactory.create()
GroupFactory.create()
UserFactory.create()
UserFactory.create()
cgroup_1 = GroupFactory.create(functional_area=True)
GroupFactory.create(functional_area=False)
eq_(set(Group.get_functional_areas()), set([cgroup_1]))
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:8,代码来源:test_models.py
示例20: test_get_curated
def test_get_curated(self):
GroupFactory.create()
GroupFactory.create()
user_1 = UserFactory.create()
user_2 = UserFactory.create()
cgroup_1 = GroupFactory.create(steward=user_1.userprofile)
cgroup_2 = GroupFactory.create(steward=user_2.userprofile)
eq_(set(Group.get_curated()), set([cgroup_1, cgroup_2]))
开发者ID:Narrator,项目名称:mozillians,代码行数:8,代码来源:test_models.py
注:本文中的mozillians.users.tests.UserFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论