コード例 #1
0
    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')
コード例 #2
0
 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.code, 'B'))
     # Run
     response = self.client.get(url)
     # Check
     assert response.status_code == 200
     assert list(response.context['theses']) == [thesis_2, thesis_5, thesis_6, ]
コード例 #3
0
 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)
コード例 #4
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
    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')
コード例 #5
0
    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
コード例 #6
0
    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,
        ])
コード例 #7
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
 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, ]
コード例 #8
0
ファイル: test_shortcuts.py プロジェクト: erudit/eruditorg
 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}
コード例 #9
0
    def test_inserts_a_dict_with_the_letters_counts_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 = self.client.get(url)

        # Check
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.context['letters_exists']), 26)
        self.assertEqual(response.context['letters_exists']['B'], 1)
        self.assertEqual(response.context['letters_exists']['C'], 2)
        for letter in 'adefghijklmnopqrstuvwxyz':
            self.assertEqual(
                response.context['letters_exists'][letter.upper()], 0)
コード例 #10
0
ファイル: test_models.py プロジェクト: erudit/erudit-core
    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
コード例 #11
0
 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}
コード例 #12
0
ファイル: test_shortcuts.py プロジェクト: erudit/eruditorg
 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}
コード例 #13
0
ファイル: test_shortcuts.py プロジェクト: erudit/eruditorg
 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, ]
コード例 #14
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
 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}
コード例 #15
0
 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.code, '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}
コード例 #16
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
    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, ])
コード例 #17
0
 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}
コード例 #18
0
 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.code, '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, ]
コード例 #19
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
 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, ]
コード例 #20
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
    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
コード例 #21
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
    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)
コード例 #22
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
    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)
コード例 #23
0
    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
コード例 #24
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
    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
コード例 #25
0
    def test_supports_authors_with_only_special_characters_in_their_name(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=':')
        article_1.authors.add(author_1)
        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)
コード例 #26
0
    def test_can_filter_by_article_type_when_no_article_of_type(
            self, mock_erudit_object):
        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)
コード例 #27
0
 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(issue=self.issue_1)
     self.article_2 = ArticleFactory.create(issue=self.issue_1)
     self.article_3 = ArticleFactory.create(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)
コード例 #28
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
    def test_inserts_a_dict_with_the_letters_counts_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 = self.client.get(url)

        # Check
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.context['letters_exists']), 26)
        self.assertEqual(response.context['letters_exists']['B'], 1)
        self.assertEqual(response.context['letters_exists']['C'], 2)
        for letter in 'adefghijklmnopqrstuvwxyz':
            self.assertEqual(response.context['letters_exists'][letter.upper()], 0)
コード例 #29
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
    def test_only_letters_with_results_are_active(self):
        """ Test that for a given selection in the authors list view, only the letters for which
        results are present are shown """
        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)
        assert response.context['letters_exists'].get('A') == 0
コード例 #30
0
 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,
     ]
コード例 #31
0
    def test_only_letters_with_results_are_active(self):
        """ Test that for a given selection in the authors list view, only the letters for which
        results are present are shown """
        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)
        assert response.context['letters_exists'].get('A') == 0
コード例 #32
0
 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}
コード例 #33
0
    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)
コード例 #34
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
 def test_inserts_collection_information_into_the_context(self):
     # Setup
     author = AuthorFactory.create()
     collection_1 = CollectionFactory.create()
     collection_2 = CollectionFactory.create()
     thesis_1 = ThesisFactory.create(  # noqa
         localidentifier='thesis-1', collection=collection_1, author=author,
         publication_year=2010)
     thesis_2 = ThesisFactory.create(
         localidentifier='thesis-2', collection=collection_1, author=author,
         publication_year=2012)
     thesis_3 = ThesisFactory.create(
         localidentifier='thesis-3', collection=collection_1, author=author,
         publication_year=2013)
     thesis_4 = ThesisFactory.create(
         localidentifier='thesis-4', collection=collection_1, author=author,
         publication_year=2014)
     thesis_5 = ThesisFactory.create(  # noqa
         localidentifier='thesis-5', collection=collection_2, author=author,
         publication_year=2010)
     thesis_6 = ThesisFactory.create(
         localidentifier='thesis-6', collection=collection_2, author=author,
         publication_year=2012)
     thesis_7 = ThesisFactory.create(
         localidentifier='thesis-7', collection=collection_2, author=author,
         publication_year=2013)
     thesis_8 = ThesisFactory.create(
         localidentifier='thesis-8', collection=collection_2, author=author,
         publication_year=2014)
     url = reverse('public:thesis:home')
     # Run
     response = self.client.get(url)
     # Check
     assert response.status_code == 200
     assert 'collections_dict' in response.context
     assert len(response.context['collections_dict']) == 2
     assert collection_1.id in response.context['collections_dict']
     assert collection_2.id in response.context['collections_dict']
     assert response.context['collections_dict'][collection_1.id]['thesis_count'] == 4
     assert response.context['collections_dict'][collection_2.id]['thesis_count'] == 4
     assert response.context['collections_dict'][collection_1.id]['recent_theses'] == \
         [thesis_4, thesis_3, thesis_2, ]
     assert response.context['collections_dict'][collection_2.id]['recent_theses'] == \
         [thesis_8, thesis_7, thesis_6, ]
コード例 #35
0
 def test_inserts_collection_information_into_the_context(self):
     # Setup
     author = AuthorFactory.create()
     collection_1 = CollectionFactory.create()
     collection_2 = CollectionFactory.create()
     thesis_1 = ThesisFactory.create(  # noqa
         localidentifier='thesis-1', collection=collection_1, author=author,
         publication_year=2010)
     thesis_2 = ThesisFactory.create(
         localidentifier='thesis-2', collection=collection_1, author=author,
         publication_year=2012)
     thesis_3 = ThesisFactory.create(
         localidentifier='thesis-3', collection=collection_1, author=author,
         publication_year=2013)
     thesis_4 = ThesisFactory.create(
         localidentifier='thesis-4', collection=collection_1, author=author,
         publication_year=2014)
     thesis_5 = ThesisFactory.create(  # noqa
         localidentifier='thesis-5', collection=collection_2, author=author,
         publication_year=2010)
     thesis_6 = ThesisFactory.create(
         localidentifier='thesis-6', collection=collection_2, author=author,
         publication_year=2012)
     thesis_7 = ThesisFactory.create(
         localidentifier='thesis-7', collection=collection_2, author=author,
         publication_year=2013)
     thesis_8 = ThesisFactory.create(
         localidentifier='thesis-8', collection=collection_2, author=author,
         publication_year=2014)
     url = reverse('public:thesis:home')
     # Run
     response = self.client.get(url)
     # Check
     assert response.status_code == 200
     assert 'collections_dict' in response.context
     assert len(response.context['collections_dict']) == 2
     assert collection_1.id in response.context['collections_dict']
     assert collection_2.id in response.context['collections_dict']
     assert response.context['collections_dict'][collection_1.id]['thesis_count'] == 4
     assert response.context['collections_dict'][collection_2.id]['thesis_count'] == 4
     assert response.context['collections_dict'][collection_1.id]['recent_theses'] == \
         [thesis_4, thesis_3, thesis_2, ]
     assert response.context['collections_dict'][collection_2.id]['recent_theses'] == \
         [thesis_8, thesis_7, thesis_6, ]
コード例 #36
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
    def test_can_filter_by_article_type(self):
        # Setup
        issue_1 = IssueFactory.create(journal=self.journal, date_published=dt.datetime.now())
        article_1 = ArticleFactory.create( issue=issue_1, type='article')
        article_2 = ArticleFactory.create( issue=issue_1, type='compterendu')  # noqa

        author_1 = AuthorFactory.create(lastname='btest')
        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='article')

        # Check
        self.assertEqual(response.status_code, 200)
        authors_dicts = response.context['authors_dicts']

        assert len(authors_dicts) == 1
コード例 #37
0
ファイル: test_models.py プロジェクト: erudit/erudit-core
    def test_can_return_articles_written_for_a_given_journal(self):
        # Setup
        other_journal = JournalFactory.create(
            publishers=[self.publisher])
        other_issue = IssueFactory.create(
            journal=other_journal, date_published=dt.datetime.now())
        other_article = ArticleFactory.create(issue=other_issue)

        issue = IssueFactory.create(
            journal=self.journal, date_published=dt.datetime.now())
        article = ArticleFactory.create(issue=issue)

        author = AuthorFactory.create()

        article.authors.add(author)
        other_article.authors.add(author)

        # Run
        self.assertEqual(list(author.articles_in_journal(self.journal)), [article, ])
コード例 #38
0
 def test_can_sort_theses_by_descending_title(self):
     # Setup
     author = AuthorFactory.create()
     collection = CollectionFactory.create()
     thesis_1 = ThesisFactory.create(  # noqa
         localidentifier='thesis-1', collection=collection, author=author,
         publication_year=2012, title='Atitle')
     thesis_2 = ThesisFactory.create(  # noqa
         localidentifier='thesis-2', collection=collection, author=author,
         publication_year=2012, title='Btitle')
     thesis_3 = ThesisFactory.create(  # noqa
         localidentifier='thesis-3', collection=collection, author=author,
         publication_year=2012, title='Ctitle')
     url = reverse('public:thesis:collection_list_per_year', args=(collection.code, 2012))
     # Run
     response = self.client.get(url, {'sort_by': 'title_desc'})
     # Check
     assert response.status_code == 200
     assert list(response.context['theses']) == [thesis_3, thesis_2, thesis_1, ]
コード例 #39
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
 def test_can_sort_theses_by_descending_title(self):
     # Setup
     author = AuthorFactory.create()
     collection = CollectionFactory.create()
     thesis_1 = ThesisFactory.create(  # noqa
         localidentifier='thesis-1', collection=collection, author=author,
         publication_year=2012, title='Atitle')
     thesis_2 = ThesisFactory.create(  # noqa
         localidentifier='thesis-2', collection=collection, author=author,
         publication_year=2012, title='Btitle')
     thesis_3 = ThesisFactory.create(  # noqa
         localidentifier='thesis-3', collection=collection, author=author,
         publication_year=2012, title='Ctitle')
     url = reverse('public:thesis:collection_list_per_year', args=(collection.id, 2012))
     # Run
     response = self.client.get(url, {'sort_by': 'title_desc'})
     # Check
     assert response.status_code == 200
     assert list(response.context['theses']) == [thesis_3, thesis_2, thesis_1, ]
コード例 #40
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
 def test_can_sort_theses_by_descending_date(self):
     # Setup
     dt_now = dt.datetime.now()
     author = AuthorFactory.create(lastname='Bname')
     collection = CollectionFactory.create()
     thesis_1 = ThesisFactory.create(  # noqa
         localidentifier='thesis-1', collection=collection, author=author,
         publication_year=2012, oai_datestamp=(dt_now - dt.timedelta(days=3)).date())
     thesis_2 = ThesisFactory.create(  # noqa
         localidentifier='thesis-2', collection=collection, author=author,
         publication_year=2012, oai_datestamp=(dt_now - dt.timedelta(days=2)).date())
     thesis_3 = ThesisFactory.create(  # noqa
         localidentifier='thesis-3', collection=collection, author=author,
         publication_year=2012, oai_datestamp=(dt_now - dt.timedelta(days=1)).date())
     url = reverse('public:thesis:collection_list_per_author_name', args=(collection.id, 'B'))
     # Run
     response = self.client.get(url, {'sort_by': 'date_desc'})
     # Check
     assert response.status_code == 200
     assert list(response.context['theses']) == [thesis_3, thesis_2, thesis_1, ]
コード例 #41
0
 def test_can_sort_theses_by_descending_date(self):
     # Setup
     dt_now = dt.datetime.now()
     author = AuthorFactory.create(lastname='Bname')
     collection = CollectionFactory.create()
     thesis_1 = ThesisFactory.create(  # noqa
         localidentifier='thesis-1', collection=collection, author=author,
         publication_year=2012, oai_datestamp=(dt_now - dt.timedelta(days=3)).date())
     thesis_2 = ThesisFactory.create(  # noqa
         localidentifier='thesis-2', collection=collection, author=author,
         publication_year=2012, oai_datestamp=(dt_now - dt.timedelta(days=2)).date())
     thesis_3 = ThesisFactory.create(  # noqa
         localidentifier='thesis-3', collection=collection, author=author,
         publication_year=2012, oai_datestamp=(dt_now - dt.timedelta(days=1)).date())
     url = reverse('public:thesis:collection_list_per_author_name', args=(collection.code, 'B'))
     # Run
     response = self.client.get(url, {'sort_by': 'date_desc'})
     # Check
     assert response.status_code == 200
     assert list(response.context['theses']) == [thesis_3, thesis_2, thesis_1, ]
コード例 #42
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
 def test_inserts_the_recent_theses_into_the_context(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(
         localidentifier='thesis-2', collection=collection, author=author,
         publication_year=2012)
     thesis_3 = ThesisFactory.create(
         localidentifier='thesis-3', collection=collection, author=author,
         publication_year=2013)
     thesis_4 = ThesisFactory.create(
         localidentifier='thesis-4', collection=collection, author=author,
         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['recent_theses'] == [thesis_4, thesis_3, thesis_2, ]
コード例 #43
0
    def test_can_filter_by_article_type(self):
        # Setup
        issue_1 = IssueFactory.create(journal=self.journal,
                                      date_published=dt.datetime.now())
        article_1 = ArticleFactory.create(issue=issue_1, type='article')
        article_2 = ArticleFactory.create(issue=issue_1,
                                          type='compterendu')  # noqa

        author_1 = AuthorFactory.create(lastname='btest')
        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='article')

        # Check
        self.assertEqual(response.status_code, 200)
        authors_dicts = response.context['authors_dicts']

        assert len(authors_dicts) == 1
コード例 #44
0
 def test_inserts_the_thesis_counts_grouped_by_publication_years(self):
     # Setup
     cache.clear()
     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)
     url = reverse('public:thesis:collection_home', args=(collection.code, ))
     # Run
     response = self.client.get(url)
     # Check
     assert response.status_code == 200
     assert response.context['thesis_groups']['by_publication_year'][0] == \
         {'publication_year': 2014, 'total': 2}
     assert response.context['thesis_groups']['by_publication_year'][1] == \
         {'publication_year': 2013, 'total': 1}
     assert response.context['thesis_groups']['by_publication_year'][2] == \
         {'publication_year': 2012, 'total': 3}
     assert response.context['thesis_groups']['by_publication_year'][3] == \
         {'publication_year': 2010, 'total': 1}
コード例 #45
0
 def test_embeds_the_other_publication_years_aggregation_results_into_the_context(self):
     # Setup
     cache.clear()
     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)
     url = reverse('public:thesis:collection_list_per_year', args=(collection.code, 2012))
     # Run
     response = self.client.get(url)
     # Check
     assert response.status_code == 200
     assert response.context['other_publication_years'][0] == \
         {'publication_year': 2014, 'total': 2}
     assert response.context['other_publication_years'][1] == \
         {'publication_year': 2013, 'total': 1}
     assert response.context['other_publication_years'][2] == \
         {'publication_year': 2012, 'total': 3}
     assert response.context['other_publication_years'][3] == \
         {'publication_year': 2010, 'total': 1}
コード例 #46
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
 def test_embeds_the_other_publication_years_aggregation_results_into_the_context(self):
     # Setup
     cache.clear()
     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)
     url = reverse('public:thesis:collection_list_per_year', args=(collection.id, 2012))
     # Run
     response = self.client.get(url)
     # Check
     assert response.status_code == 200
     assert response.context['other_publication_years'][0] == \
         {'publication_year': 2014, 'total': 2}
     assert response.context['other_publication_years'][1] == \
         {'publication_year': 2013, 'total': 1}
     assert response.context['other_publication_years'][2] == \
         {'publication_year': 2012, 'total': 3}
     assert response.context['other_publication_years'][3] == \
         {'publication_year': 2010, 'total': 1}
コード例 #47
0
ファイル: test_views.py プロジェクト: erudit/eruditorg
 def test_inserts_the_thesis_counts_grouped_by_publication_years(self):
     # Setup
     cache.clear()
     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)
     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_publication_year'][0] == \
         {'publication_year': 2014, 'total': 2}
     assert response.context['thesis_groups']['by_publication_year'][1] == \
         {'publication_year': 2013, 'total': 1}
     assert response.context['thesis_groups']['by_publication_year'][2] == \
         {'publication_year': 2012, 'total': 3}
     assert response.context['thesis_groups']['by_publication_year'][3] == \
         {'publication_year': 2010, 'total': 1}
コード例 #48
0
 def test_inserts_the_recent_theses_into_the_context(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(
         localidentifier='thesis-2', collection=collection, author=author,
         publication_year=2012)
     thesis_3 = ThesisFactory.create(
         localidentifier='thesis-3', collection=collection, author=author,
         publication_year=2013)
     thesis_4 = ThesisFactory.create(
         localidentifier='thesis-4', collection=collection, author=author,
         publication_year=2014)
     url = reverse('public:thesis:collection_home', args=(collection.code, ))
     # Run
     response = self.client.get(url)
     # Check
     assert response.status_code == 200
     assert response.context['recent_theses'] == [thesis_4, thesis_3, thesis_2, ]