本文整理汇总了Python中erudit.test.factories.JournalFactory.save方法的典型用法代码示例。如果您正苦于以下问题:Python JournalFactory.save方法的具体用法?Python JournalFactory.save怎么用?Python JournalFactory.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类erudit.test.factories.JournalFactory
的用法示例。
在下文中一共展示了JournalFactory.save方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_shows_the_individual_subscription_authorization_section_with_management
# 需要导入模块: from erudit.test.factories import JournalFactory [as 别名]
# 或者: from erudit.test.factories.JournalFactory import save [as 别名]
def test_shows_the_individual_subscription_authorization_section_with_management(self):
# Setup
journal = JournalFactory(collection=self.collection)
journal.members.add(self.user_granted)
journal.save()
ct = ContentType.objects.get(app_label="erudit", model="journal")
Authorization.objects.create(
content_type=ct,
user=self.user_granted,
object_id=journal.id,
authorization_codename=AC.can_manage_authorizations.codename)
plan = JournalManagementPlanFactory.create(max_accounts=10)
JournalManagementSubscriptionFactory.create(journal=journal, plan=plan)
self.client.login(username=self.user_granted.username,
password="user")
url = reverse('userspace:journal:authorization:list', args=(journal.pk, ))
# Run
response = self.client.get(url, {'codename': AC.can_manage_authorizations.codename})
# Check
self.assertEqual(response.status_code, 200)
self.assertTrue(
AC.can_manage_individual_subscription.codename
in response.context['authorizations'])
示例2: test_permission_delete_restricted
# 需要导入模块: from erudit.test.factories import JournalFactory [as 别名]
# 或者: from erudit.test.factories.JournalFactory import save [as 别名]
def test_permission_delete_restricted(self):
self.client.login(username=self.user_non_granted.username,
password="user")
journal = JournalFactory(collection=self.collection)
journal.save()
self.client.login(username=self.user_granted.username,
password="user")
ct = ContentType.objects.get(app_label="erudit", model="journal")
authorization = Authorization.objects.create(
content_type=ct,
user=self.user_granted,
object_id=journal.id,
authorization_codename=AC.can_manage_authorizations.codename)
url = reverse('userspace:journal:authorization:delete',
args=(journal.pk, authorization.pk, ))
response = self.client.get(url)
self.assertEqual(response.status_code, 403)
journal.members.add(self.user_granted)
journal.save()
response = self.client.get(url, follow=True)
self.assertEqual(response.status_code, 200)
示例3: test_knows_if_a_user_cannot_manage_authorizations
# 需要导入模块: from erudit.test.factories import JournalFactory [as 别名]
# 或者: from erudit.test.factories.JournalFactory import save [as 别名]
def test_knows_if_a_user_cannot_manage_authorizations(self):
user = UserFactory()
journal = JournalFactory(collection=self.collection)
is_granted = user.has_perm('authorization.manage_authorizations', journal)
self.assertEqual(is_granted, False)
journal.members.add(user)
journal.save()
is_granted = user.has_perm('authorization.manage_authorizations', journal)
self.assertEqual(is_granted, False)
示例4: test_knows_if_a_user_can_manage_authorizations
# 需要导入模块: from erudit.test.factories import JournalFactory [as 别名]
# 或者: from erudit.test.factories.JournalFactory import save [as 别名]
def test_knows_if_a_user_can_manage_authorizations(self):
user = UserFactory()
journal = JournalFactory(collection=self.collection)
journal.members.add(user)
journal.save()
ct = ContentType.objects.get(app_label="erudit", model="journal")
Authorization.objects.create(
content_type=ct,
user=user,
object_id=journal.id,
authorization_codename=AC.can_manage_authorizations.codename)
is_granted = user.has_perm('authorization.manage_authorizations', journal)
self.assertEqual(is_granted, True)
示例5: test_permission_list_restricted
# 需要导入模块: from erudit.test.factories import JournalFactory [as 别名]
# 或者: from erudit.test.factories.JournalFactory import save [as 别名]
def test_permission_list_restricted(self):
journal = JournalFactory(collection=self.collection)
journal.members.add(self.user_granted)
journal.save()
self.client.login(username=self.user_non_granted.username,
password="user")
url = reverse('userspace:journal:authorization:list', args=(journal.pk, ))
response = self.client.get(url)
self.assertEqual(response.status_code, 403)
response = self.client.get(url)
self.assertEqual(response.status_code, 403)
示例6: test_user_can_manage
# 需要导入模块: from erudit.test.factories import JournalFactory [as 别名]
# 或者: from erudit.test.factories.JournalFactory import save [as 别名]
def test_user_can_manage(self):
journal = JournalFactory(collection=self.collection)
user = UserFactory()
journal.members.add(user)
journal.save()
ct = ContentType.objects.get(app_label="erudit", model="journal")
Authorization.objects.create(
content_type=ct,
user=user,
object_id=journal.id,
authorization_codename=AC.can_manage_issuesubmission.codename)
issue = IssueSubmissionFactory(journal=journal)
is_granted = user.has_perm('editor.manage_issuesubmission',
issue.journal)
self.assertEqual(is_granted, True)
示例7: test_contact_filter
# 需要导入模块: from erudit.test.factories import JournalFactory [as 别名]
# 或者: from erudit.test.factories.JournalFactory import save [as 别名]
def test_contact_filter(self):
user = UserFactory()
user2 = UserFactory()
journal_in = JournalFactory(collection=self.collection)
journal_in.members.add(user)
journal_in.save()
journal_not_in = JournalFactory(collection=self.collection)
journal_not_in.members.add(user2)
journal_not_in.save()
data = {'user': user, 'journal': journal_in}
form = IssueSubmissionForm(**data)
choices = [c[0] for c in form.fields['contact'].choices]
self.assertTrue(user.id in choices)
self.assertFalse(user2.id in choices)
示例8: test_issuesubmission_add_granted
# 需要导入模块: from erudit.test.factories import JournalFactory [as 别名]
# 或者: from erudit.test.factories.JournalFactory import save [as 别名]
def test_issuesubmission_add_granted(self):
journal = JournalFactory(collection=self.collection)
journal.save()
journal.members.add(self.user_granted)
self.client.login(username=self.user_granted.username,
password="user")
url = reverse('userspace:journal:editor:add', kwargs={'journal_pk': journal.pk})
response = self.client.get(url)
self.assertEqual(response.status_code, 403)
ct = ContentType.objects.get(app_label="erudit", model="journal")
Authorization.objects.create(
content_type=ct,
user=self.user_granted,
object_id=journal.id,
authorization_codename=AC.can_manage_issuesubmission.codename)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
示例9: test_returns_an_http_404_error_if_the_codename_is_not_known
# 需要导入模块: from erudit.test.factories import JournalFactory [as 别名]
# 或者: from erudit.test.factories.JournalFactory import save [as 别名]
def test_returns_an_http_404_error_if_the_codename_is_not_known(self):
# Setup
journal = JournalFactory(collection=self.collection)
journal.members.add(self.user_granted)
journal.save()
ct = ContentType.objects.get(app_label="erudit", model="journal")
Authorization.objects.create(
content_type=ct,
user=self.user_granted,
object_id=journal.id,
authorization_codename=AC.can_manage_authorizations.codename)
self.client.login(username=self.user_granted.username,
password="user")
url = reverse('userspace:journal:authorization:create', args=(journal.pk, ))
# Run
response = self.client.get(url, {'codename': 'dummy'})
# Check
self.assertEqual(response.status_code, 404)