当前位置: 首页>>代码示例>>Python>>正文


Python AuthorFactory.create方法代码示例

本文整理汇总了Python中erudit.test.factories.AuthorFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Python AuthorFactory.create方法的具体用法?Python AuthorFactory.create怎么用?Python AuthorFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在erudit.test.factories.AuthorFactory的用法示例。


在下文中一共展示了AuthorFactory.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_can_determine_the_thesis_counts_per_author_firstletter

# 需要导入模块: from erudit.test.factories import AuthorFactory [as 别名]
# 或者: from erudit.test.factories.AuthorFactory import create [as 别名]
 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,代码行数:37,代码来源:test_shortcuts.py

示例2: test_inserts_the_current_letter_in_the_context

# 需要导入模块: from erudit.test.factories import AuthorFactory [as 别名]
# 或者: from erudit.test.factories.AuthorFactory import create [as 别名]
    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,代码行数:28,代码来源:test_views.py

示例3: setup

# 需要导入模块: from erudit.test.factories import AuthorFactory [as 别名]
# 或者: from erudit.test.factories.AuthorFactory import create [as 别名]
 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,代码行数:34,代码来源:test_views.py

示例4: test_returns_only_theses_for_a_given_author_first_letter

# 需要导入模块: from erudit.test.factories import AuthorFactory [as 别名]
# 或者: from erudit.test.factories.AuthorFactory import create [as 别名]
 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,代码行数:36,代码来源:test_views.py

示例5: test_can_return_its_letter_prefix

# 需要导入模块: from erudit.test.factories import AuthorFactory [as 别名]
# 或者: from erudit.test.factories.AuthorFactory import create [as 别名]
    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,代码行数:16,代码来源:test_models.py

示例6: test_can_determine_the_thesis_counts_per_publication_year

# 需要导入模块: from erudit.test.factories import AuthorFactory [as 别名]
# 或者: from erudit.test.factories.AuthorFactory import create [as 别名]
 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,代码行数:34,代码来源:test_shortcuts.py

示例7: test_returns_only_collections_associated_with_theses

# 需要导入模块: from erudit.test.factories import AuthorFactory [as 别名]
# 或者: from erudit.test.factories.AuthorFactory import create [as 别名]
 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,代码行数:12,代码来源:test_shortcuts.py

示例8: test_embeds_the_other_author_first_letter_aggregation_results_into_the_context

# 需要导入模块: from erudit.test.factories import AuthorFactory [as 别名]
# 或者: from erudit.test.factories.AuthorFactory import create [as 别名]
 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,代码行数:44,代码来源:test_views.py

示例9: test_provides_only_authors_for_the_first_available_letter_by_default

# 需要导入模块: from erudit.test.factories import AuthorFactory [as 别名]
# 或者: from erudit.test.factories.AuthorFactory import create [as 别名]
    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,代码行数:22,代码来源:test_views.py

示例10: test_inserts_the_thesis_counts_grouped_by_author_name

# 需要导入模块: from erudit.test.factories import AuthorFactory [as 别名]
# 或者: from erudit.test.factories.AuthorFactory import create [as 别名]
 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,代码行数:43,代码来源:test_views.py

示例11: test_can_filter_by_article_type_when_no_article_of_type

# 需要导入模块: from erudit.test.factories import AuthorFactory [as 别名]
# 或者: from erudit.test.factories.AuthorFactory import create [as 别名]
    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,代码行数:14,代码来源:test_views.py

示例12: test_only_provides_authors_for_the_given_letter

# 需要导入模块: from erudit.test.factories import AuthorFactory [as 别名]
# 或者: from erudit.test.factories.AuthorFactory import create [as 别名]
    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,代码行数:23,代码来源:test_views.py

示例13: test_can_sort_theses_by_descending_author_name

# 需要导入模块: from erudit.test.factories import AuthorFactory [as 别名]
# 或者: from erudit.test.factories.AuthorFactory import create [as 别名]
 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,代码行数:23,代码来源:test_views.py

示例14: test_do_not_fail_when_user_requests_a_letter_with_no_articles

# 需要导入模块: from erudit.test.factories import AuthorFactory [as 别名]
# 或者: from erudit.test.factories.AuthorFactory import create [as 别名]
    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,代码行数:15,代码来源:test_views.py

示例15: test_can_provide_contributors_of_article

# 需要导入模块: from erudit.test.factories import AuthorFactory [as 别名]
# 或者: from erudit.test.factories.AuthorFactory import create [as 别名]
    def test_can_provide_contributors_of_article(self):
        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']
        contributors = authors_dicts[0]['articles'][0]['contributors']

        assert len(contributors) == 1
        assert contributors[0].pk == author_2.pk
开发者ID:erudit,项目名称:eruditorg,代码行数:25,代码来源:test_views.py


注:本文中的erudit.test.factories.AuthorFactory.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。