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


Python factories.AuthorFactory類代碼示例

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


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

示例1: 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

示例2: test_returns_only_theses_for_a_given_author_first_letter

 def test_returns_only_theses_for_a_given_author_first_letter(self):
     # Setup
     author_1 = AuthorFactory.create(lastname='Aname')
     author_2 = AuthorFactory.create(lastname='Bname')
     author_3 = AuthorFactory.create(lastname='Cname')
     author_4 = AuthorFactory.create(lastname='Dname')
     collection = CollectionFactory.create()
     thesis_1 = ThesisFactory.create(  # noqa
         localidentifier='thesis-1', collection=collection, author=author_1,
         publication_year=2010)
     thesis_2 = ThesisFactory.create(  # noqa
         localidentifier='thesis-2', collection=collection, author=author_2,
         publication_year=2012)
     thesis_3 = ThesisFactory.create(  # noqa
         localidentifier='thesis-3', collection=collection, author=author_3,
         publication_year=2013)
     thesis_4 = ThesisFactory.create(  # noqa
         localidentifier='thesis-4', collection=collection, author=author_4,
         publication_year=2014)
     thesis_5 = ThesisFactory.create(  # noqa
         localidentifier='thesis-5', collection=collection, author=author_2,
         publication_year=2012)
     thesis_6 = ThesisFactory.create(  # noqa
         localidentifier='thesis-6', collection=collection, author=author_2,
         publication_year=2012)
     thesis_7 = ThesisFactory.create(  # noqa
         localidentifier='thesis-7', collection=collection, author=author_4,
         publication_year=2014)
     url = reverse('public:thesis:collection_list_per_author_name', args=(collection.id, 'B'))
     # Run
     response = self.client.get(url)
     # Check
     assert response.status_code == 200
     assert list(response.context['theses']) == [thesis_2, thesis_5, thesis_6, ]
開發者ID:erudit,項目名稱:eruditorg,代碼行數:34,代碼來源:test_views.py

示例3: test_inserts_the_current_letter_in_the_context

    def test_inserts_the_current_letter_in_the_context(self):
        # Setup
        issue_1 = IssueFactory.create(journal=self.journal, date_published=dt.datetime.now())
        article_1 = ArticleFactory.create(issue=issue_1)

        author_1 = AuthorFactory.create(lastname='btest')
        author_2 = AuthorFactory.create(lastname='ctest1')
        author_3 = AuthorFactory.create(lastname='ctest2')

        article_1.authors.add(author_1)
        article_1.authors.add(author_2)
        article_1.authors.add(author_3)
        url = reverse('public:journal:journal_authors_list', kwargs={'code': self.journal.code})

        # Run
        response_1 = self.client.get(url)
        response_2 = self.client.get(url, {'letter': 'C'})
        response_3 = self.client.get(url, {'letter': 'invalid'})

        # Check
        self.assertEqual(response_1.status_code, 200)
        self.assertEqual(response_2.status_code, 200)
        self.assertEqual(response_3.status_code, 200)
        self.assertEqual(response_1.context['letter'], 'B')
        self.assertEqual(response_2.context['letter'], 'C')
        self.assertEqual(response_3.context['letter'], 'B')
開發者ID:erudit,項目名稱:eruditorg,代碼行數:26,代碼來源:test_views.py

示例4: test_can_determine_the_thesis_counts_per_author_firstletter

 def test_can_determine_the_thesis_counts_per_author_firstletter(self):
     # Setup
     author_1 = AuthorFactory.create(lastname='Aname')
     author_2 = AuthorFactory.create(lastname='Bname')
     author_3 = AuthorFactory.create(lastname='Cname')
     author_4 = AuthorFactory.create(lastname='Dname')
     collection = CollectionFactory.create()
     thesis_1 = ThesisFactory.create(  # noqa
         localidentifier='thesis-1', collection=collection, author=author_1,
         publication_year=2010)
     thesis_2 = ThesisFactory.create(  # noqa
         localidentifier='thesis-2', collection=collection, author=author_2,
         publication_year=2012)
     thesis_3 = ThesisFactory.create(  # noqa
         localidentifier='thesis-3', collection=collection, author=author_3,
         publication_year=2013)
     thesis_4 = ThesisFactory.create(  # noqa
         localidentifier='thesis-4', collection=collection, author=author_4,
         publication_year=2014)
     thesis_5 = ThesisFactory.create(  # noqa
         localidentifier='thesis-5', collection=collection, author=author_2,
         publication_year=2012)
     thesis_6 = ThesisFactory.create(  # noqa
         localidentifier='thesis-6', collection=collection, author=author_2,
         publication_year=2012)
     thesis_7 = ThesisFactory.create(  # noqa
         localidentifier='thesis-7', collection=collection, author=author_4,
         publication_year=2014)
     # Run
     aggs = get_thesis_counts_per_author_first_letter(Thesis.objects.all())
     # Check
     assert aggs[0] == {'author_firstletter': 'A', 'total': 1}
     assert aggs[1] == {'author_firstletter': 'B', 'total': 3}
     assert aggs[2] == {'author_firstletter': 'C', 'total': 1}
     assert aggs[3] == {'author_firstletter': 'D', 'total': 2}
開發者ID:erudit,項目名稱:eruditorg,代碼行數:35,代碼來源:test_shortcuts.py

示例5: test_can_return_its_name

    def test_can_return_its_name(self):
        author_1 = AuthorFactory()

        assert str(author_1) == "{lastname}, {firstname}".format(
            lastname=author_1.lastname, firstname=author_1.firstname
        )

        author_1.suffix = 'PhD'

        assert str(author_1) == "{suffix} {firstname} {lastname}".format(
            suffix=author_1.suffix, firstname=author_1.firstname, lastname=author_1.lastname
        )
開發者ID:erudit,項目名稱:erudit-core,代碼行數:12,代碼來源:test_models.py

示例6: test_can_return_its_letter_prefix

    def test_can_return_its_letter_prefix(self):
        # Setup
        author_1 = AuthorFactory.create(lastname='Abc', firstname='Def')
        author_2 = AuthorFactory.create(lastname=None, firstname='Def')
        author_3 = AuthorFactory.create(lastname=None, firstname='Def', othername='Ghi')
        author_4 = AuthorFactory.create(lastname=':', firstname='Def')
        author_5 = AuthorFactory.create(lastname=':', firstname=None)

        # Run & check
        assert author_1.letter_prefix == 'A'
        assert author_2.letter_prefix == 'D'
        assert author_3.letter_prefix == 'G'
        assert author_4.letter_prefix == 'D'
        assert author_5.letter_prefix is None
開發者ID:erudit,項目名稱:erudit-core,代碼行數:14,代碼來源:test_models.py

示例7: test_can_determine_the_thesis_counts_per_publication_year

 def test_can_determine_the_thesis_counts_per_publication_year(self):
     # Setup
     author = AuthorFactory.create()
     collection = CollectionFactory.create()
     thesis_1 = ThesisFactory.create(  # noqa
         localidentifier='thesis-1', collection=collection, author=author,
         publication_year=2010)
     thesis_2 = ThesisFactory.create(  # noqa
         localidentifier='thesis-2', collection=collection, author=author,
         publication_year=2012)
     thesis_3 = ThesisFactory.create(  # noqa
         localidentifier='thesis-3', collection=collection, author=author,
         publication_year=2013)
     thesis_4 = ThesisFactory.create(  # noqa
         localidentifier='thesis-4', collection=collection, author=author,
         publication_year=2014)
     thesis_5 = ThesisFactory.create(  # noqa
         localidentifier='thesis-5', collection=collection, author=author,
         publication_year=2012)
     thesis_6 = ThesisFactory.create(  # noqa
         localidentifier='thesis-6', collection=collection, author=author,
         publication_year=2012)
     thesis_7 = ThesisFactory.create(  # noqa
         localidentifier='thesis-7', collection=collection, author=author,
         publication_year=2014)
     # Run
     aggs = get_thesis_counts_per_publication_year(Thesis.objects.all())
     # Check
     assert aggs[0] == {'publication_year': 2014, 'total': 2}
     assert aggs[1] == {'publication_year': 2013, 'total': 1}
     assert aggs[2] == {'publication_year': 2012, 'total': 3}
     assert aggs[3] == {'publication_year': 2010, 'total': 1}
開發者ID:erudit,項目名稱:eruditorg,代碼行數:32,代碼來源:test_shortcuts.py

示例8: test_returns_only_collections_associated_with_theses

 def test_returns_only_collections_associated_with_theses(self):
     # Setup
     author = AuthorFactory.create()
     collection_1 = CollectionFactory.create(localidentifier='col1')
     collection_2 = CollectionFactory.create(localidentifier='col2')
     CollectionFactory.create(localidentifier='col3')
     ThesisFactory.create(localidentifier='thesis1', collection=collection_1, author=author)
     ThesisFactory.create(localidentifier='thesis2', collection=collection_2, author=author)
     # Run & check
     assert list(get_thesis_collections()) == [collection_1, collection_2, ]
開發者ID:erudit,項目名稱:eruditorg,代碼行數:10,代碼來源:test_shortcuts.py

示例9: test_embeds_the_other_author_first_letter_aggregation_results_into_the_context

 def test_embeds_the_other_author_first_letter_aggregation_results_into_the_context(self):
     # Setup
     cache.clear()
     author_1 = AuthorFactory.create(lastname='Aname')
     author_2 = AuthorFactory.create(lastname='Bname')
     author_3 = AuthorFactory.create(lastname='Cname')
     author_4 = AuthorFactory.create(lastname='Dname')
     collection = CollectionFactory.create()
     thesis_1 = ThesisFactory.create(  # noqa
         localidentifier='thesis-1', collection=collection, author=author_1,
         publication_year=2010)
     thesis_2 = ThesisFactory.create(  # noqa
         localidentifier='thesis-2', collection=collection, author=author_2,
         publication_year=2012)
     thesis_3 = ThesisFactory.create(  # noqa
         localidentifier='thesis-3', collection=collection, author=author_3,
         publication_year=2013)
     thesis_4 = ThesisFactory.create(  # noqa
         localidentifier='thesis-4', collection=collection, author=author_4,
         publication_year=2014)
     thesis_5 = ThesisFactory.create(  # noqa
         localidentifier='thesis-5', collection=collection, author=author_2,
         publication_year=2012)
     thesis_6 = ThesisFactory.create(  # noqa
         localidentifier='thesis-6', collection=collection, author=author_2,
         publication_year=2012)
     thesis_7 = ThesisFactory.create(  # noqa
         localidentifier='thesis-7', collection=collection, author=author_4,
         publication_year=2014)
     url = reverse('public:thesis:collection_list_per_author_name', args=(collection.id, 'B'))
     # Run
     response = self.client.get(url)
     # Check
     assert response.status_code == 200
     assert response.context['other_author_letters'][0] == \
         {'author_firstletter': 'A', 'total': 1}
     assert response.context['other_author_letters'][1] == \
         {'author_firstletter': 'B', 'total': 3}
     assert response.context['other_author_letters'][2] == \
         {'author_firstletter': 'C', 'total': 1}
     assert response.context['other_author_letters'][3] == \
         {'author_firstletter': 'D', 'total': 2}
開發者ID:erudit,項目名稱:eruditorg,代碼行數:42,代碼來源:test_views.py

示例10: test_provides_only_authors_for_the_first_available_letter_by_default

    def test_provides_only_authors_for_the_first_available_letter_by_default(self):
        # Setup
        issue_1 = IssueFactory.create(journal=self.journal, date_published=dt.datetime.now())
        article_1 = ArticleFactory.create(issue=issue_1)

        author_1 = AuthorFactory.create(lastname='btest')
        author_2 = AuthorFactory.create(lastname='ctest1')
        author_3 = AuthorFactory.create(lastname='ctest2')

        article_1.authors.add(author_1)
        article_1.authors.add(author_2)
        article_1.authors.add(author_3)
        url = reverse('public:journal:journal_authors_list', kwargs={'code': self.journal.code})

        # Run
        response = self.client.get(url)

        # Check
        self.assertEqual(response.status_code, 200)
        self.assertEqual(list(response.context['authors']), [author_1, ])
開發者ID:erudit,項目名稱:eruditorg,代碼行數:20,代碼來源:test_views.py

示例11: test_inserts_the_thesis_counts_grouped_by_author_name

 def test_inserts_the_thesis_counts_grouped_by_author_name(self):
     # Setup
     author_1 = AuthorFactory.create(lastname='Aname')
     author_2 = AuthorFactory.create(lastname='Bname')
     author_3 = AuthorFactory.create(lastname='Cname')
     author_4 = AuthorFactory.create(lastname='Dname')
     collection = CollectionFactory.create()
     thesis_1 = ThesisFactory.create(  # noqa
         localidentifier='thesis-1', collection=collection, author=author_1,
         publication_year=2010)
     thesis_2 = ThesisFactory.create(  # noqa
         localidentifier='thesis-2', collection=collection, author=author_2,
         publication_year=2012)
     thesis_3 = ThesisFactory.create(  # noqa
         localidentifier='thesis-3', collection=collection, author=author_3,
         publication_year=2013)
     thesis_4 = ThesisFactory.create(  # noqa
         localidentifier='thesis-4', collection=collection, author=author_4,
         publication_year=2014)
     thesis_5 = ThesisFactory.create(  # noqa
         localidentifier='thesis-5', collection=collection, author=author_2,
         publication_year=2012)
     thesis_6 = ThesisFactory.create(  # noqa
         localidentifier='thesis-6', collection=collection, author=author_2,
         publication_year=2012)
     thesis_7 = ThesisFactory.create(  # noqa
         localidentifier='thesis-7', collection=collection, author=author_4,
         publication_year=2014)
     url = reverse('public:thesis:collection_home', args=(collection.id, ))
     # Run
     response = self.client.get(url)
     # Check
     assert response.status_code == 200
     assert response.context['thesis_groups']['by_author_name'][0] == \
         {'author_firstletter': 'A', 'total': 1}
     assert response.context['thesis_groups']['by_author_name'][1] == \
         {'author_firstletter': 'B', 'total': 3}
     assert response.context['thesis_groups']['by_author_name'][2] == \
         {'author_firstletter': 'C', 'total': 1}
     assert response.context['thesis_groups']['by_author_name'][3] == \
         {'author_firstletter': 'D', 'total': 2}
開發者ID:savoirfairelinux,項目名稱:eruditorg,代碼行數:41,代碼來源:test_views.py

示例12: test_can_sort_theses_by_descending_author_name

 def test_can_sort_theses_by_descending_author_name(self):
     # Setup
     author_1 = AuthorFactory.create(lastname='BAname')
     author_2 = AuthorFactory.create(lastname='BBname')
     author_3 = AuthorFactory.create(lastname='BCname')
     collection = CollectionFactory.create()
     thesis_1 = ThesisFactory.create(  # noqa
         localidentifier='thesis-1', collection=collection, author=author_1,
         publication_year=2012)
     thesis_2 = ThesisFactory.create(  # noqa
         localidentifier='thesis-2', collection=collection, author=author_2,
         publication_year=2012)
     thesis_3 = ThesisFactory.create(  # noqa
         localidentifier='thesis-3', collection=collection, author=author_3,
         publication_year=2012)
     url = reverse('public:thesis:collection_list_per_author_name', args=(collection.id, 'B'))
     # Run
     response = self.client.get(url, {'sort_by': 'author_desc'})
     # Check
     assert response.status_code == 200
     assert list(response.context['theses']) == [thesis_3, thesis_2, thesis_1, ]
開發者ID:erudit,項目名稱:eruditorg,代碼行數:21,代碼來源:test_views.py

示例13: test_can_filter_by_article_type_when_no_article_of_type

    def test_can_filter_by_article_type_when_no_article_of_type(self):
        issue_1 = IssueFactory.create(journal=self.journal, date_published=dt.datetime.now())
        article_1 = ArticleFactory.create( issue=issue_1, type='article')
        author_1 = AuthorFactory.create(lastname='atest')
        article_1.authors.add(author_1)
        url = reverse('public:journal:journal_authors_list', kwargs={'code': self.journal.code})

        # Run
        response = self.client.get(url, {"article_type": 'compterendu'})

        # Check
        self.assertEqual(response.status_code, 200)
開發者ID:erudit,項目名稱:eruditorg,代碼行數:12,代碼來源:test_views.py

示例14: test_only_provides_authors_for_the_given_letter

    def test_only_provides_authors_for_the_given_letter(self):
        # Seetup
        issue_1 = IssueFactory.create(journal=self.journal, date_published=dt.datetime.now())
        article_1 = ArticleFactory.create( issue=issue_1)

        author_1 = AuthorFactory.create(lastname='btest')
        author_2 = AuthorFactory.create(lastname='ctest1')

        article_1.authors.add(author_1)
        article_1.authors.add(author_2)
        article_1.save()
        url = reverse('public:journal:journal_authors_list', kwargs={'code': self.journal.code})

        # Run
        response = self.client.get(url, letter='b')

        # Check
        self.assertEqual(response.status_code, 200)
        authors_dicts = response.context['authors_dicts']
        assert len(authors_dicts) == 1
        assert authors_dicts[0]['author'] == author_1
開發者ID:erudit,項目名稱:eruditorg,代碼行數:21,代碼來源:test_views.py

示例15: test_do_not_fail_when_user_requests_a_letter_with_no_articles

    def test_do_not_fail_when_user_requests_a_letter_with_no_articles(self):
        # Setup
        issue_1 = IssueFactory.create(journal=self.journal, date_published=dt.datetime.now())
        article_1 = ArticleFactory.create(issue=issue_1, type='article')
        author_1 = AuthorFactory.create(lastname='btest')
        article_1.authors.add(author_1)

        url = reverse('public:journal:journal_authors_list', kwargs={'code': self.journal.code})

        response = self.client.get(url, {"article_type": 'compterendu', 'letter': 'A'})

        # Check
        self.assertEqual(response.status_code, 200)
開發者ID:erudit,項目名稱:eruditorg,代碼行數:13,代碼來源:test_views.py


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