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


Python factories.JournalFactory類代碼示例

本文整理匯總了Python中erudit.test.factories.JournalFactory的典型用法代碼示例。如果您正苦於以下問題:Python JournalFactory類的具體用法?Python JournalFactory怎麽用?Python JournalFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了JournalFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_journals_with_published_issues_are_not_upcoming

 def test_journals_with_published_issues_are_not_upcoming(self):
     # Setup
     JournalFactory.create_with_issue()
     # Run
     journals = Journal.upcoming_objects.all()
     # Check
     assert list(journals) == []
開發者ID:erudit,項目名稱:erudit-core,代碼行數:7,代碼來源:test_managers.py

示例2: test_shows_the_individual_subscription_authorization_section_with_management

    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,代碼行數:29,代碼來源:test_views.py

示例3: test_permission_delete_restricted

    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,代碼行數:27,代碼來源:test_views.py

示例4: setup

 def setup(self):
     author_1 = AuthorFactory.create(lastname='Abc', firstname='Def')
     author_2 = AuthorFactory.create(lastname='Def', firstname='ghi')
     JournalType.objects.create(code='S')
     JournalType.objects.create(code='C')
     self.collection_1 = CollectionFactory.create()
     self.thesis_1 = ThesisFactory.create(
         localidentifier='t1', collection=self.collection_1, author=author_1, title='Thesis A',
         publication_year=2014)
     self.thesis_2 = ThesisFactory.create(
         localidentifier='t2', collection=self.collection_1, author=author_2, title='Thesis B',
         publication_year=2011)
     author_3 = AuthorFactory.create(lastname='Ghi', firstname='Jkl')
     author_4 = AuthorFactory.create(lastname='Jkl', firstname='mno')
     self.journal_1 = JournalFactory.create(
         collection=self.collection, type=JournalType.objects.get(code='S'))
     self.journal_2 = JournalFactory.create(
         collection=self.collection, type=JournalType.objects.get(code='C'))
     self.issue_1 = IssueFactory.create(journal=self.journal_1, year=2012)
     self.issue_2 = IssueFactory.create(journal=self.journal_2, year=2013)
     self.article_1 = ArticleFactory.create(title='Title A', issue=self.issue_1)
     self.article_2 = ArticleFactory.create(title='Title B', issue=self.issue_1)
     self.article_3 = ArticleFactory.create(title='Title C', issue=self.issue_2)
     self.article_1.authors.add(author_3)
     self.article_2.authors.add(author_4)
     self.article_3.authors.add(author_3)
     clist = SavedCitationListFactory.create(user=self.user)
     clist.documents.add(self.thesis_1)
     clist.documents.add(self.thesis_2)
     clist.documents.add(self.article_1)
     clist.documents.add(self.article_2)
     clist.documents.add(self.article_3)
開發者ID:savoirfairelinux,項目名稱:eruditorg,代碼行數:32,代碼來源:test_views.py

示例5: test_embeds_the_upcoming_journals_into_the_context

 def test_embeds_the_upcoming_journals_into_the_context(self):
     # Setup
     JournalFactory.create(collection=self.collection, upcoming=False)
     url = reverse('public:home')
     # Run
     response = self.client.get(url)
     # Check
     self.assertEqual(response.status_code, 200)
開發者ID:erudit,項目名稱:eruditorg,代碼行數:8,代碼來源:test_views.py

示例6: test_only_main_collections_are_shown_by_default

    def test_only_main_collections_are_shown_by_default(self):
        collection = CollectionFactory.create()
        main_collection = CollectionFactory.create(is_main_collection=True)
        journal1 = JournalFactory.create(collection=collection)
        journal2 = JournalFactory.create(collection=main_collection)
        url = reverse('public:journal:journal_list')
        response = self.client.get(url)

        assert list(response.context['journals']) == [journal2]
開發者ID:erudit,項目名稱:eruditorg,代碼行數:9,代碼來源:test_views.py

示例7: test_can_return_its_letter_prefix

 def test_can_return_its_letter_prefix(self):
     # Setup
     journal_1 = JournalFactory.create(
         name='Test', collection=self.collection, publishers=[self.publisher])
     journal_2 = JournalFactory.create(
         name=None, collection=self.collection, publishers=[self.publisher])
     # Run & check
     self.assertEqual(journal_1.letter_prefix, 'T')
     self.assertIsNone(journal_2.letter_prefix)
開發者ID:erudit,項目名稱:erudit-core,代碼行數:9,代碼來源:test_models.py

示例8: test_knows_if_a_user_cannot_manage_authorizations

    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,代碼行數:10,代碼來源:test_rules.py

示例9: test_can_filter_the_journals_by_open_access

 def test_can_filter_the_journals_by_open_access(self):
     # Setup
     collection = CollectionFactory.create()
     journal_1 = JournalFactory.create(collection=collection, open_access=True)
     JournalFactory.create(collection=collection, open_access=False)
     url = reverse('public:journal:journal_list')
     # Run
     response = self.client.get(url, data={'open_access': True})
     # Check
     assert list(response.context['journals']) == [journal_1, ]
開發者ID:erudit,項目名稱:eruditorg,代碼行數:10,代碼來源:test_views.py

示例10: test_knows_that_it_is_in_open_access_if_its_issue_is_in_open_access

 def test_knows_that_it_is_in_open_access_if_its_issue_is_in_open_access(self):
     # Setup
     j1 = JournalFactory.create(open_access=True)
     j2 = JournalFactory.create(open_access=False)
     issue_1 = IssueFactory.create(journal=j1)
     article_1 = ArticleFactory.create(issue=issue_1)
     issue_2 = IssueFactory.create(journal=j2)
     article_2 = ArticleFactory.create(issue=issue_2)
     # Run 1 check
     self.assertTrue(article_1.open_access)
     self.assertFalse(article_2.open_access)
開發者ID:erudit,項目名稱:erudit-core,代碼行數:11,代碼來源:test_models.py

示例11: test_can_filter_the_journals_by_collections

 def test_can_filter_the_journals_by_collections(self):
     # Setup
     col_1 = CollectionFactory(code='col1')
     col_2 = CollectionFactory(code='col2')
     JournalFactory.create(collection=col_1)
     journal_2 = JournalFactory.create(collection=col_2)
     url = reverse('public:journal:journal_list')
     # Run
     response = self.client.get(url, data={'collections': ['col2', ]})
     # Check
     assert list(response.context['journals']) == [journal_2, ]
開發者ID:erudit,項目名稱:eruditorg,代碼行數:11,代碼來源:test_views.py

示例12: test_returns_only_the_internal_journals

 def test_returns_only_the_internal_journals(self):
     # Setup
     journal_1 = JournalFactory.create(
         collection=self.collection,
         external_url='http://example.com',
         redirect_to_external_url=True
     )
     JournalFactory.create(collection=self.collection)
     # Run
     journals = Journal.internal_objects.all()
     # Check
     self.assertTrue(journal_1 not in journals)
開發者ID:erudit,項目名稱:erudit-core,代碼行數:12,代碼來源:test_managers.py

示例13: test_can_filter_the_journals_by_types

 def test_can_filter_the_journals_by_types(self):
     # Setup
     collection = CollectionFactory.create()
     jtype_1 = JournalType.objects.create(code='T1', name='T1')
     jtype_2 = JournalType.objects.create(code='T2', name='T2')
     JournalFactory.create(collection=collection, type=jtype_1)
     journal_2 = JournalFactory.create(collection=collection, type=jtype_2)
     url = reverse('public:journal:journal_list')
     # Run
     response = self.client.get(url, data={'types': ['T2', ]})
     # Check
     assert list(response.context['journals']) == [journal_2, ]
開發者ID:erudit,項目名稱:eruditorg,代碼行數:12,代碼來源:test_views.py

示例14: test_knows_if_a_user_can_manage_authorizations

 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,代碼行數:13,代碼來源:test_rules.py

示例15: test_permission_list_restricted

    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,代碼行數:14,代碼來源:test_views.py


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