當前位置: 首頁>>代碼示例>>Python>>正文


Python JournalFactory.save方法代碼示例

本文整理匯總了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'])
開發者ID:erudit,項目名稱:eruditorg,代碼行數:31,代碼來源:test_views.py

示例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)
開發者ID:erudit,項目名稱:eruditorg,代碼行數:29,代碼來源:test_views.py

示例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)
開發者ID:erudit,項目名稱:eruditorg,代碼行數:12,代碼來源:test_rules.py

示例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)
開發者ID:erudit,項目名稱:eruditorg,代碼行數:15,代碼來源:test_rules.py

示例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)
開發者ID:erudit,項目名稱:eruditorg,代碼行數:16,代碼來源:test_views.py

示例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)
開發者ID:erudit,項目名稱:eruditorg,代碼行數:18,代碼來源:test_permissions.py

示例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)
開發者ID:erudit,項目名稱:eruditorg,代碼行數:20,代碼來源:test_forms.py

示例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)
開發者ID:erudit,項目名稱:eruditorg,代碼行數:21,代碼來源:test_permissions.py

示例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)
開發者ID:erudit,項目名稱:eruditorg,代碼行數:25,代碼來源:test_views.py


注:本文中的erudit.test.factories.JournalFactory.save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。