Esempio n. 1
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)
Esempio n. 2
0
 def test_can_return_all_the_articles_associated_with_the_last_issue_of_a_journal(self, mock_erudit_object):  # noqa
     # Setup
     mock_erudit_object.return_value = get_mocked_erudit_object()
     issue1 = IssueFactory.create(
         journal=self.journal, year=2010, date_published=dt.datetime.now())
     article1 = ArticleFactory.create(issue=issue1)
     article2 = ArticleFactory.create(issue=issue1)
     issue2 = IssueFactory.create(
         journal=self.journal, year=2010,
         date_published=dt.datetime.now() - dt.timedelta(days=2))
     ArticleFactory.create(issue=issue2)
     request = self.factory.get('/')
     # Run
     f = LatestJournalArticlesFeed()
     f.get_object(request, self.journal.code)
     feed = f.get_feed(None, request)
     # Check
     self.assertEqual(len(feed.items), 2)
     self.assertIn(
         reverse('public:journal:article_detail',
                 args=[
                     article1.issue.journal.code,
                     article1.issue.volume_slug,
                     article1.issue.localidentifier,
                     article1.localidentifier
                 ]), feed.items[0]['link'])
     self.assertIn(
         reverse('public:journal:article_detail',
                 args=[
                     article2.issue.journal.code,
                     article2.issue.volume_slug,
                     article2.issue.localidentifier,
                     article2.localidentifier
                 ]), feed.items[1]['link'])
Esempio n. 3
0
    def test_can_grant_access_to_an_article_has_no_movable_limitation(self):
        # Setup
        now_dt = dt.datetime.now()

        self.journal.open_access = False
        self.journal.save()
        issue = IssueFactory.create(
            journal=self.journal, year=dt.datetime.now().year - 5,
            date_published=dt.date(now_dt.year - 5, 3, 20),
            localidentifier='test')
        IssueFactory.create(
            journal=self.journal, year=dt.datetime.now().year - 5,
            date_published=now_dt,
            localidentifier='test2')
        article = ArticleFactory.create(issue=issue)

        class MyView(ArticleAccessCheckMixin):
            def get_article(self):
                return article

        request = self.factory.get('/')
        request.user = AnonymousUser()
        request.session = dict()
        view = MyView()
        view.request = request

        # Run # check
        self.assertTrue(view.has_access())
Esempio n. 4
0
 def test_can_return_all_the_issues_published_since_a_specific_date(self):
     # Setup
     issue1 = IssueFactory.create(journal=self.journal,
                                  date_published=dt.datetime.now())
     issue2 = IssueFactory.create(journal=self.journal,
                                  date_published=dt.datetime.now() -
                                  dt.timedelta(days=20))
     IssueFactory.create(journal=self.journal,
                         date_published=dt.datetime.now() -
                         dt.timedelta(days=110))
     request = self.factory.get('/')
     # Run
     feed = LatestIssuesFeed().get_feed(None, request)
     # Check
     self.assertEqual(len(feed.items), 2)
     self.assertIn(
         reverse('public:journal:issue_detail',
                 args=[
                     issue1.journal.code, issue1.volume_slug,
                     issue1.localidentifier
                 ]), feed.items[0]['link'])
     self.assertIn(
         reverse('public:journal:issue_detail',
                 args=[
                     issue2.journal.code, issue2.volume_slug,
                     issue2.localidentifier
                 ]), feed.items[1]['link'])
Esempio n. 5
0
 def test_returns_only_the_internal_issues(self):
     # Setup
     issue_1 = IssueFactory.create(journal=self.journal, external_url=None)
     issue_2 = IssueFactory.create(journal=self.journal, external_url='http://example.com')
     # Run
     issues = Issue.internal_objects.all()
     # Check
     self.assertTrue(issue_1 in issues)
     self.assertTrue(issue_2 not in issues)
Esempio n. 6
0
 def test_knows_that_it_is_in_open_access_if_its_issue_is_in_open_access(self):
     # Setup
     j1 = JournalFactory.create(open_access=True)
     j2 = JournalFactory.create(open_access=False)
     issue_1 = IssueFactory.create(journal=j1)
     article_1 = ArticleFactory.create(issue=issue_1)
     issue_2 = IssueFactory.create(journal=j2)
     article_2 = ArticleFactory.create(issue=issue_2)
     # Run 1 check
     self.assertTrue(article_1.open_access)
     self.assertFalse(article_2.open_access)
Esempio n. 7
0
 def test_can_return_its_first_issue(self):
     # Setup
     issue_1 = IssueFactory.create(
         journal=self.journal, year=2010,
         date_published=dt.datetime.now() - dt.timedelta(days=1))
     IssueFactory.create(journal=self.journal, year=2010, date_published=dt.datetime.now())
     IssueFactory.create(
         journal=self.journal, year=dt.datetime.now().year + 2,
         date_published=dt.datetime.now() + dt.timedelta(days=30))
     # Run & check
     self.assertEqual(self.journal.first_issue, issue_1)
Esempio n. 8
0
 def test_embeds_the_latest_issues_into_the_context(self):
     # Setup
     issue_1 = IssueFactory.create(
         journal=self.journal, date_published=dt.datetime.now() - dt.timedelta(days=1))
     issue_2 = IssueFactory.create(journal=self.journal, date_published=dt.datetime.now())
     url = reverse('public:home')
     # Run
     response = self.client.get(url)
     # Check
     self.assertEqual(response.status_code, 200)
     self.assertEqual(list(response.context['latest_issues']), [issue_2, issue_1, ])
Esempio n. 9
0
    def test_knows_its_editors(self):
        now_dt = dt.datetime.now()
        first_issue = IssueFactory.create(
            journal=self.journal, date_published=now_dt - dt.timedelta(days=1)
        )
        first_issue_editor = IssueContributorFactory(issue=first_issue, is_editor=True)

        last_issue = IssueFactory.create(journal=self.journal, date_published=now_dt)
        last_issue_editor = IssueContributorFactory(issue=last_issue, is_editor=True)

        assert last_issue_editor in self.journal.get_editors()
        assert first_issue_editor not in self.journal.get_editors()
Esempio n. 10
0
    def test_can_return_its_published_issues(self):
        # Setup
        issue_1 = IssueFactory.create(journal=self.journal, year=2010)
        issue_2 = IssueFactory.create(journal=self.journal, year=2009)

        # Create an unpublished issue
        IssueFactory.create(
            journal=self.journal, is_published=False,
            year=dt.datetime.now().year + 2
        )
        # Run & check
        self.assertEqual(set(self.journal.published_issues), {issue_1, issue_2})
Esempio n. 11
0
 def test_can_mark_issues_as_unpublished(self):
     # Setup
     issue_1 = IssueFactory.create(journal=self.journal, is_published=True)
     issue_2 = IssueFactory.create(journal=self.journal, is_published=True)
     issue_3 = IssueFactory.create(journal=self.journal, is_published=True)
     queryset = Issue.objects.filter(id__in=(issue_1.id, issue_2.id, ))
     # Run
     self.admin.make_unpublished(self.admin, mock.MagicMock(), queryset)
     issue_1 = Issue.objects.get(id=issue_1.id)
     issue_2 = Issue.objects.get(id=issue_2.id)
     issue_3 = Issue.objects.get(id=issue_3.id)
     self.assertFalse(issue_1.is_published)
     self.assertFalse(issue_2.is_published)
     self.assertTrue(issue_3.is_published)
Esempio n. 12
0
 def test_can_mark_issues_force_free_access_to_false(self):
     # Setup
     issue_1 = IssueFactory.create(journal=self.journal, force_free_access=True)
     issue_2 = IssueFactory.create(journal=self.journal, force_free_access=True)
     issue_3 = IssueFactory.create(journal=self.journal, force_free_access=True)
     queryset = Issue.objects.filter(id__in=(issue_1.id, issue_2.id, ))
     # Run
     self.admin.force_free_access_to_false(self.admin, mock.MagicMock(), queryset)
     issue_1 = Issue.objects.get(id=issue_1.id)
     issue_2 = Issue.objects.get(id=issue_2.id)
     issue_3 = Issue.objects.get(id=issue_3.id)
     self.assertFalse(issue_1.force_free_access)
     self.assertFalse(issue_2.force_free_access)
     self.assertTrue(issue_3.force_free_access)
Esempio n. 13
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')
Esempio n. 14
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
Esempio n. 15
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,
        ])
Esempio n. 16
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)
Esempio n. 17
0
    def test_can_retrieve_the_first_page_of_the_pdf_of_existing_articles(self, mock_ds, mock_pdf):
        # Setup
        with open(os.path.join(FIXTURE_ROOT, 'dummy-multipages.pdf'), 'rb') as f:
            mock_pdf.content = io.BytesIO()
            mock_pdf.content.write(f.read())
        mock_ds = ['ERUDITXSD300', ]  # noqa

        issue = IssueFactory.create(
            journal=self.journal, date_published=dt.datetime.now() - dt.timedelta(days=1000))
        article = ArticleFactory.create(issue=issue)
        journal_id = self.journal.localidentifier
        issue_id = issue.localidentifier
        article_id = article.localidentifier
        url = reverse('public:journal:article_raw_pdf_firstpage', args=(
            journal_id, issue.volume_slug, issue_id, article_id
        ))
        request = self.factory.get(url)
        request.user = AnonymousUser()

        # Run
        response = ArticleRawPdfFirstPageView.as_view()(
            request, journal_code=journal_id, issue_slug=issue.volume_slug,
            issue_localid=issue_id, localid=article_id)

        # Check
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response['Content-Type'], 'application/pdf')
        raw_pdf = io.BytesIO()
        raw_pdf.write(response.content)
        pdf = PdfFileReader(raw_pdf)
        self.assertEqual(pdf.numPages, 1)
Esempio n. 18
0
    def test_cannot_grant_access_to_an_article_if_it_is_associated_to_an_institutional_account_that_is_not_not_ongoing(
        self
    ):  # noqa
        # Setup
        self.journal.open_access = False
        self.journal.save()
        issue = IssueFactory.create(
            journal=self.journal, year=dt.datetime.now().year, date_published=dt.datetime.now(), localidentifier="test"
        )
        article = ArticleFactory.create(issue=issue)

        organisation = OrganisationFactory.create()

        subscription = JournalAccessSubscriptionFactory.create(journal=self.journal, organisation=organisation)

        InstitutionIPAddressRangeFactory.create(subscription=subscription, ip_start="192.168.1.2", ip_end="192.168.1.4")

        class MyView(ArticleAccessCheckMixin):
            def get_article(self):
                return article

        request = self.factory.get("/")
        request.user = AnonymousUser()
        # FIXME call middleware
        request.subscription = None
        parameters = request.META.copy()
        parameters["HTTP_X_FORWARDED_FOR"] = "192.168.1.3"
        request.META = parameters

        view = MyView()
        view.request = request

        # Run # check
        self.assertFalse(view.has_access())
Esempio n. 19
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')
Esempio n. 20
0
    def test_can_grant_access_to_an_article_if_it_is_associated_to_an_individual_subscription(self):
        # Setup
        self.journal.open_access = False
        self.journal.save()
        issue = IssueFactory.create(
            journal=self.journal, year=dt.datetime.now().year, date_published=dt.datetime.now(),
            localidentifier='test')
        article = ArticleFactory.create(issue=issue)

        now_dt = dt.datetime.now()

        subscription = JournalAccessSubscriptionFactory.create(user=self.user, journal=self.journal)
        JournalAccessSubscriptionPeriodFactory.create(
            subscription=subscription,
            start=now_dt - dt.timedelta(days=10),
            end=now_dt + dt.timedelta(days=8))

        class MyView(ArticleAccessCheckMixin):
            def get_article(self):
                return article

        request = self.factory.get('/')
        request.user = self.user
        request.session = dict()
        view = MyView()
        view.request = request
        middleware.process_request(request)

        # Run # check
        self.assertTrue(view.has_access())
Esempio n. 21
0
    def test_can_grant_access_to_an_article_if_it_is_associated_to_an_individual_subscription(self):
        # Setup
        self.journal.open_access = False
        self.journal.save()
        issue = IssueFactory.create(
            journal=self.journal, year=dt.datetime.now().year, date_published=dt.datetime.now(), localidentifier="test"
        )
        article = ArticleFactory.create(issue=issue)

        now_dt = dt.datetime.now()

        subscription = JournalAccessSubscriptionFactory.create(user=self.user, journal=self.journal)
        JournalAccessSubscriptionPeriodFactory.create(
            subscription=subscription, start=now_dt - dt.timedelta(days=10), end=now_dt + dt.timedelta(days=8)
        )

        class MyView(ArticleAccessCheckMixin):
            def get_article(self):
                return article

        request = self.factory.get("/")
        request.user = self.user
        view = MyView()
        view.request = request
        middleware.process_request(request)

        # Run # check
        self.assertTrue(view.has_access())
Esempio n. 22
0
    def test_cannot_grant_access_to_an_article_if_it_is_associated_to_an_individual_subscription_that_is_not_ongoing(
        self
    ):  # noqa
        # Setup
        self.journal.open_access = False
        self.journal.save()
        issue = IssueFactory.create(
            journal=self.journal, year=dt.datetime.now().year, date_published=dt.datetime.now(), localidentifier="test"
        )
        article = ArticleFactory.create(issue=issue)

        JournalAccessSubscriptionFactory.create(user=self.user, journal=self.journal)

        class MyView(ArticleAccessCheckMixin):
            def get_article(self):
                return article

        request = self.factory.get("/")
        request.user = self.user
        request.subscription = None
        view = MyView()
        view.request = request

        # Run # check
        self.assertFalse(view.has_access())
Esempio n. 23
0
    def test_can_grant_access_to_an_article_has_no_movable_limitation(self):
        # Setup
        now_dt = dt.datetime.now()

        self.journal.open_access = False
        self.journal.save()
        issue = IssueFactory.create(
            journal=self.journal,
            year=dt.datetime.now().year - 5,
            date_published=dt.date(now_dt.year - 5, 3, 20),
            localidentifier="test",
        )
        article = ArticleFactory.create(issue=issue)

        class MyView(ArticleAccessCheckMixin):
            def get_article(self):
                return article

        request = self.factory.get("/")
        request.user = AnonymousUser()
        view = MyView()
        view.request = request

        # Run # check
        self.assertTrue(view.has_access())
Esempio n. 24
0
    def test_can_retrieve_xml_of_existing_articles(self, mock_ds, mock_pdf):

        with open(os.path.join(FIXTURE_ROOT, '1023796ar.xml'), 'r') as f:
            from eulxml.xmlmap import load_xmlobject_from_file
            mock_pdf.content = load_xmlobject_from_file(f)
        mock_ds = ['ERUDITXSD300', ]  # noqa

        issue = IssueFactory.create(
            journal=self.journal, year=2010,
            date_published=dt.datetime.now() - dt.timedelta(days=1000))
        article = ArticleFactory.create(issue=issue)
        journal_id = self.journal.localidentifier
        issue_id = issue.localidentifier
        article_id = article.localidentifier
        url = reverse('public:journal:article_raw_xml', args=(
            journal_id, issue.volume_slug, issue_id, article_id
        ))
        request = self.factory.get(url)
        request.user = AnonymousUser()
        request.subscription = None

        # Run
        response = ArticleXmlView.as_view()(
            request, journal_code=journal_id, issue_slug=issue.volume_slug, issue_localid=issue_id,
            localid=article_id)

        # Check
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response['Content-Type'], 'application/xml')
Esempio n. 25
0
    def test_cannot_be_accessed_if_the_publication_of_the_article_is_not_allowed_by_its_authors(
            self):  # noqa
        # Setup
        self.journal.open_access = False
        self.journal.save()
        issue = IssueFactory.create(journal=self.journal,
                                    year=2010,
                                    date_published=dt.datetime.now())
        article = ArticleFactory.create(issue=issue, publication_allowed=False)
        journal_id = self.journal.localidentifier
        issue_id = issue.localidentifier
        article_id = article.localidentifier
        url = reverse('public:journal:article_raw_pdf',
                      args=(journal_id, issue.volume_slug, issue_id,
                            article_id))
        request = self.factory.get(url)
        request.user = AnonymousUser()

        # Run & check
        response = ArticleRawPdfView.as_view()(request,
                                               journal_code=journal_id,
                                               issue_slug=issue.volume_slug,
                                               issue_localid=issue_id,
                                               localid=article_id)

        assert isinstance(response, HttpResponseRedirect)
        assert response.url == reverse('public:journal:article_detail',
                                       args=(journal_id, issue.volume_slug,
                                             issue_id, article_id))
Esempio n. 26
0
 def test_embeds_the_latest_issues_into_the_context(self):
     # Setup
     issue_1 = IssueFactory.create(journal=self.journal,
                                   date_published=dt.datetime.now() -
                                   dt.timedelta(days=1))
     issue_2 = IssueFactory.create(journal=self.journal,
                                   date_published=dt.datetime.now())
     url = reverse('public:home')
     # Run
     response = self.client.get(url)
     # Check
     self.assertEqual(response.status_code, 200)
     self.assertEqual(list(response.context['latest_issues']), [
         issue_2,
         issue_1,
     ])
Esempio n. 27
0
 def test_generates_a_pdf_into_a_bytes_stream_by_default(self):
     # Setup
     issue = IssueFactory.create(journal=self.journal)
     article = ArticleFactory.create(issue=issue)
     # Run & check
     pdf = generate_pdf('public/journal/article_pdf_coverpage.html', context={
         'article': article, 'issue': issue, 'journal': issue.journal})
     self.assertTrue(isinstance(pdf, io.BytesIO))
Esempio n. 28
0
 def test_can_embed_the_latest_issue_in_the_context(self):
     # Setup
     collection = CollectionFactory.create(localidentifier='erudit')
     journal = JournalFactory.create(collection=collection)
     JournalInformationFactory.create(journal=journal)
     IssueFactory.create(
         journal=journal, year=2010, date_published=dt.datetime.now() - dt.timedelta(days=1))
     issue_2 = IssueFactory.create(journal=journal, year=2010, date_published=dt.datetime.now())
     IssueFactory.create(
         journal=journal, year=dt.datetime.now().year + 1,
         date_published=dt.datetime.now() + dt.timedelta(days=30))
     url = reverse('public:journal:journal_detail', kwargs={'code': journal.code})
     # Run
     response = self.client.get(url)
     # Check
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.context['latest_issue'], issue_2)
Esempio n. 29
0
    def test_knows_if_it_has_a_coverpage(self):
        # Setup
        self.journal.open_access = True
        self.journal.save()
        with open(settings.MEDIA_ROOT + '/coverpage.png', 'rb') as f:
            issue_1 = IssueFactory.create(journal=self.journal)
            issue_2 = IssueFactory.create(journal=self.journal)
            issue_1.fedora_object = unittest.mock.MagicMock()
            issue_1.fedora_object.coverpage = unittest.mock.MagicMock()
            issue_1.fedora_object.coverpage.content = io.BytesIO(f.read())
            issue_2.fedora_object = unittest.mock.MagicMock()
            issue_2.fedora_object.coverpage = unittest.mock.MagicMock()
            issue_2.fedora_object.coverpage.content = ''

        # Run & check
        self.assertTrue(issue_1.has_coverpage)
        self.assertFalse(issue_2.has_coverpage)
Esempio n. 30
0
    def test_can_redirect_to_issue_external_url(self):
        issue = IssueFactory.create(journal=self.journal,
                                    date_published=dt.datetime.now(),
                                    external_url="http://www.erudit.org")

        response = self.client.get(
            reverse('public:journal:issue_external_redirect',
                    kwargs={'localidentifier': issue.localidentifier}))
        assert response.status_code == 302
Esempio n. 31
0
 def test_works_with_pks(self):
     # Setup
     issue = IssueFactory.create(journal=self.journal, date_published=dt.datetime.now())
     url = reverse('public:journal:issue_detail', args=[
         self.journal.code, issue.volume_slug, issue.localidentifier])
     # Run
     response = self.client.get(url)
     # Check
     self.assertEqual(response.status_code, 200)
Esempio n. 32
0
 def test_knows_if_it_is_embargoed(self):
     # Setup
     now_dt = dt.date.today()
     from erudit.conf.settings import SCIENTIFIC_JOURNAL_EMBARGO_IN_MONTHS as ml
     self.journal.open_access = False
     self.journal.last_publication_year = now_dt.year
     self.journal.type = JournalTypeFactory.create(code='S')
     self.journal.save()
     date_issue_1 = dt.date(now_dt.year, now_dt.month, 1)
     date_issue_2 = now_dt - dr.relativedelta(months=ml)
     date_issue_3 = dt.date(
         now_dt.year,
         now_dt.month,
         1
     ) - dr.relativedelta(months=ml)
     date_issue_4 = now_dt - dr.relativedelta(months=(ml + 5))
     date_issue_5 = now_dt - dr.relativedelta(months=((ml + 5) * 2))
     issue_1 = IssueFactory.create(
         journal=self.journal, year=date_issue_1.year,
         date_published=date_issue_1)
     issue_2 = IssueFactory.create(
         journal=self.journal, year=date_issue_2.year,
         date_published=date_issue_2)
     issue_3 = IssueFactory.create(
         journal=self.journal, year=date_issue_3.year,
         date_published=date_issue_3)
     issue_4 = IssueFactory.create(
         journal=self.journal, year=date_issue_4.year,
         date_published=date_issue_4)
     issue_5 = IssueFactory.create(
         journal=self.journal, year=date_issue_5.year,
         date_published=date_issue_5)
     article_1 = ArticleFactory.create(issue=issue_1)
     article_2 = ArticleFactory.create(issue=issue_2)
     article_3 = ArticleFactory.create(issue=issue_3)
     article_4 = ArticleFactory.create(issue=issue_4)
     article_5 = ArticleFactory.create(issue=issue_5)
     # Run & check
     self.assertTrue(article_1.embargoed)
     self.assertTrue(article_2.embargoed)
     self.assertTrue(article_3.embargoed)
     self.assertFalse(article_4.embargoed)
     self.assertFalse(article_5.embargoed)
Esempio n. 33
0
    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, ])
Esempio n. 34
0
 def test_issues_with_a_next_year_published_date_are_embargoed(self):
     now_dt = dt.datetime.now()
     self.journal.last_publication_year = now_dt.year + 1
     self.journal.type = JournalTypeFactory.create(code='C')
     self.journal.save()
     issue = IssueFactory.create(
         journal=self.journal,
         year=now_dt.year + 1, date_published=dt.date(now_dt.year + 1, 1, 1)
     )
     assert issue.embargoed is True
Esempio n. 35
0
 def test_works_with_pks(self, mock_fedora_mixin):
     # Setup
     issue = IssueFactory.create(journal=self.journal,
                                 date_published=dt.datetime.now())
     url = reverse(
         'public:journal:issue_detail',
         args=[self.journal.code, issue.volume_slug, issue.localidentifier])
     # Run
     response = self.client.get(url)
     # Check
     self.assertEqual(response.status_code, 200)
Esempio n. 36
0
 def test_can_return_all_the_issues_published_since_a_specific_date(self):
     # Setup
     issue1 = IssueFactory.create(journal=self.journal, date_published=dt.datetime.now())
     issue2 = IssueFactory.create(
         journal=self.journal, date_published=dt.datetime.now() - dt.timedelta(days=20))
     IssueFactory.create(
         journal=self.journal, date_published=dt.datetime.now() - dt.timedelta(days=110))
     request = self.factory.get('/')
     # Run
     feed = LatestIssuesFeed().get_feed(None, request)
     # Check
     self.assertEqual(len(feed.items), 2)
     self.assertIn(
         reverse('public:journal:issue_detail',
                 args=[issue1.journal.code, issue1.volume_slug, issue1.localidentifier]),
         feed.items[0]['link'])
     self.assertIn(
         reverse('public:journal:issue_detail',
                 args=[issue2.journal.code, issue2.volume_slug, issue2.localidentifier]),
         feed.items[1]['link'])
Esempio n. 37
0
 def test_generates_a_pdf_into_a_bytes_stream_by_default(self):
     # Setup
     issue = IssueFactory.create(journal=self.journal)
     article = ArticleFactory.create(issue=issue)
     # Run & check
     pdf = generate_pdf('public/journal/article_pdf_coverpage.html',
                        context={
                            'article': article,
                            'issue': issue,
                            'journal': issue.journal
                        })
     self.assertTrue(isinstance(pdf, io.BytesIO))
Esempio n. 38
0
 def test_knows_that_issues_with_open_access_are_not_embargoed(self):
     # Setup
     now_dt = dt.datetime.now()
     j2 = JournalFactory.create(open_access=False)
     self.journal.last_publication_year = now_dt.year
     self.journal.open_access = True
     self.journal.type = JournalTypeFactory.create(code='C')
     self.journal.save()
     issue_1 = IssueFactory.create(
         journal=self.journal, year=now_dt.year - 1,
         date_published=dt.date(now_dt.year - 1, 3, 20))
     issue_2 = IssueFactory.create(
         journal=self.journal, year=now_dt.year - 2,
         date_published=dt.date(now_dt.year - 2, 3, 20))
     issue_3 = IssueFactory.create(
         journal=j2, year=now_dt.year,
         date_published=dt.date(now_dt.year, 3, 20))
     # Run & check
     self.assertFalse(issue_1.embargoed)
     self.assertFalse(issue_2.embargoed)
     self.assertFalse(issue_3.embargoed)
Esempio n. 39
0
    def test_knows_that_an_issue_with_an_empty_coverpage_has_no_coverpage(self):
        # Setup
        self.journal.open_access = True
        self.journal.save()
        with open(settings.MEDIA_ROOT + '/coverpage_empty.png', 'rb') as f:
            issue = IssueFactory.create(journal=self.journal)
            issue.fedora_object = unittest.mock.MagicMock()
            issue.fedora_object.coverpage = unittest.mock.MagicMock()
            issue.fedora_object.coverpage.content = io.BytesIO(f.read())

        # Run & check
        self.assertFalse(issue.has_coverpage)
Esempio n. 40
0
    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)
Esempio n. 41
0
 def test_can_generate_a_pdf_into_a_http_response(self):
     # Setup
     issue = IssueFactory.create(journal=self.journal)
     article = ArticleFactory.create(issue=issue)
     response = HttpResponse(content_type='application/pdf')
     # Run & check
     generate_pdf(
         'public/journal/article_pdf_coverpage.html',
         file_object=response, context={
             'article': article, 'issue': issue, 'journal': issue.journal})
     self.assertTrue(isinstance(response.content, bytes))
     self.assertTrue(response.tell())
Esempio n. 42
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)
Esempio n. 43
0
    def test_can_retrieve_the_article_using_the_local_identifier(self):
        # Setup
        issue_1 = IssueFactory.create(journal=self.journal, date_published=dt.datetime.now())
        article_1 = ArticleFactory.create(issue=issue_1, localidentifier='test_article')

        class MyView(SingleArticleMixin, DetailView):
            model = Article

        view = MyView()
        view.kwargs = {'localid': article_1.localidentifier}

        # Run & check
        self.assertEqual(view.get_object(), article_1)
Esempio n. 44
0
    def test_can_retrieve_the_pdf_of_existing_articles(self, mock_check_call,
                                                       mock_ds, mock_pdf,
                                                       mock_erudit_object):
        # Setup
        with open(os.path.join(FIXTURE_ROOT, 'dummy.pdf'), 'rb') as f:
            mock_pdf.content = io.BytesIO()
            mock_pdf.content.write(f.read())
        mock_ds = [
            'ERUDITXSD300',
        ]  # noqa
        issue = IssueFactory.create(journal=self.journal,
                                    year=2010,
                                    date_published=dt.datetime.now() -
                                    dt.timedelta(days=1000))
        IssueFactory.create(journal=self.journal,
                            year=2010,
                            date_published=dt.datetime.now())
        article = ArticleFactory.create(issue=issue)
        journal_id = self.journal.localidentifier
        issue_id = issue.localidentifier
        article_id = article.localidentifier
        url = reverse('public:journal:article_raw_pdf',
                      args=(journal_id, issue.volume_slug, issue_id,
                            article_id))
        request = self.factory.get(url)
        request.user = AnonymousUser()
        request.subscription = None

        # Run
        response = ArticleRawPdfView.as_view()(request,
                                               journal_code=journal_id,
                                               issue_slug=issue.volume_slug,
                                               issue_localid=issue_id,
                                               localid=article_id)

        # Check
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response['Content-Type'], 'application/pdf')
Esempio n. 45
0
    def test_can_retrieve_xml_of_existing_articles(self, mock_ds, mock_pdf):

        with open(os.path.join(FIXTURE_ROOT, '1023796ar.xml'), 'r') as f:
            from eulxml.xmlmap import load_xmlobject_from_file
            mock_pdf.content = load_xmlobject_from_file(f)
        mock_ds = [
            'ERUDITXSD300',
        ]  # noqa

        issue = IssueFactory.create(journal=self.journal,
                                    year=2010,
                                    date_published=dt.datetime.now() -
                                    dt.timedelta(days=1000))
        IssueFactory.create(journal=self.journal,
                            year=2010,
                            date_published=dt.datetime.now())
        article = ArticleFactory.create(issue=issue)
        journal_id = self.journal.localidentifier
        issue_id = issue.localidentifier
        article_id = article.localidentifier
        url = reverse('public:journal:article_raw_xml',
                      args=(journal_id, issue.volume_slug, issue_id,
                            article_id))
        request = self.factory.get(url)
        request.user = AnonymousUser()
        request.subscription = None

        # Run
        response = ArticleXmlView.as_view()(request,
                                            journal_code=journal_id,
                                            issue_slug=issue.volume_slug,
                                            issue_localid=issue_id,
                                            localid=article_id)

        # Check
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response['Content-Type'], 'application/xml')
Esempio n. 46
0
 def test_can_return_all_the_articles_associated_with_the_last_issue_of_a_journal(
         self, mock_erudit_object):  # noqa
     # Setup
     mock_erudit_object.return_value = get_mocked_erudit_object()
     issue1 = IssueFactory.create(journal=self.journal,
                                  year=2010,
                                  date_published=dt.datetime.now())
     article1 = ArticleFactory.create(issue=issue1)
     article2 = ArticleFactory.create(issue=issue1)
     issue2 = IssueFactory.create(journal=self.journal,
                                  year=2010,
                                  date_published=dt.datetime.now() -
                                  dt.timedelta(days=2))
     ArticleFactory.create(issue=issue2)
     request = self.factory.get('/')
     # Run
     f = LatestJournalArticlesFeed()
     f.get_object(request, self.journal.code)
     feed = f.get_feed(None, request)
     # Check
     self.assertEqual(len(feed.items), 2)
     self.assertIn(
         reverse('public:journal:article_detail',
                 args=[
                     article1.issue.journal.code,
                     article1.issue.volume_slug,
                     article1.issue.localidentifier,
                     article1.localidentifier
                 ]), feed.items[0]['link'])
     self.assertIn(
         reverse('public:journal:article_detail',
                 args=[
                     article2.issue.journal.code,
                     article2.issue.volume_slug,
                     article2.issue.localidentifier,
                     article2.localidentifier
                 ]), feed.items[1]['link'])
Esempio n. 47
0
 def test_can_add_new_articles(self):
     # Setup
     issue = IssueFactory.create(journal=self.journal)
     article_1 = ArticleFactory.create(issue=issue)
     article_2 = ArticleFactory.create(issue=issue)
     request = self.factory.get('/')
     middleware = SessionMiddleware()
     middleware.process_request(request)
     citation_list = SavedCitationList(request)
     # Run
     citation_list.add(article_1)
     citation_list.add(article_2)
     # Check
     self.assertTrue(article_1 in citation_list)
     self.assertTrue(article_2.id in citation_list)
Esempio n. 48
0
 def test_can_properly_handle_the_case_where_an_item_is_no_longer_in_the_citation_list(
         self):
     # Setup
     issue = IssueFactory.create(journal=self.journal)
     article = ArticleFactory.create(issue=issue)
     request = self.factory.post('/')
     request.user = AnonymousUser()
     SessionMiddleware().process_request(request)
     SavedCitationListMiddleware().process_request(request)
     view = SavedCitationRemoveView.as_view()
     # Run
     response = view(request, article.id)
     # Check
     assert response.status_code == 200
     assert 'error' in json.loads(force_text(response.content))
Esempio n. 49
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)
Esempio n. 50
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)
Esempio n. 51
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)
Esempio n. 52
0
 def test_can_embed_the_latest_issue_in_the_context(self):
     # Setup
     collection = CollectionFactory.create(localidentifier='erudit')
     journal = JournalFactory.create(collection=collection)
     JournalInformationFactory.create(journal=journal)
     IssueFactory.create(journal=journal,
                         year=2010,
                         date_published=dt.datetime.now() -
                         dt.timedelta(days=1))
     issue_2 = IssueFactory.create(journal=journal,
                                   year=2010,
                                   date_published=dt.datetime.now())
     issue_3 = IssueFactory.create(is_published=False,
                                   journal=journal,
                                   year=dt.datetime.now().year + 1,
                                   date_published=dt.datetime.now() +
                                   dt.timedelta(days=30))
     url = reverse('public:journal:journal_detail',
                   kwargs={'code': journal.code})
     # Run
     response = self.client.get(url)
     # Check
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.context['latest_issue'], issue_2)
Esempio n. 53
0
 def test_can_remove_an_article_from_a_citation_list(self):
     # Setup
     issue = IssueFactory.create(journal=self.journal)
     article = ArticleFactory.create(issue=issue)
     request = self.factory.post('/')
     request.user = AnonymousUser()
     SessionMiddleware().process_request(request)
     SavedCitationListMiddleware().process_request(request)
     request.saved_citations.add(article)
     view = SavedCitationRemoveView.as_view()
     # Run
     response = view(request, article.id)
     # Check
     assert response.status_code == 200
     assert not len(request.saved_citations)
Esempio n. 54
0
 def test_can_generate_a_pdf_into_a_http_response(self):
     # Setup
     issue = IssueFactory.create(journal=self.journal)
     article = ArticleFactory.create(issue=issue)
     response = HttpResponse(content_type='application/pdf')
     # Run & check
     generate_pdf('public/journal/article_pdf_coverpage.html',
                  file_object=response,
                  context={
                      'article': article,
                      'issue': issue,
                      'journal': issue.journal
                  })
     self.assertTrue(isinstance(response.content, bytes))
     self.assertTrue(response.tell())
Esempio n. 55
0
 def test_can_save_the_set_of_articles_to_the_session(self):
     # Setup
     issue = IssueFactory.create(journal=self.journal)
     article = ArticleFactory.create(issue=issue)
     request = self.factory.get('/')
     request.user = AnonymousUser()
     middleware = SessionMiddleware()
     middleware.process_request(request)
     citation_list = SavedCitationList(request)
     citation_list.add(article)
     # Run
     citation_list.save()
     # Check
     self.assertEqual(request.session['saved-citations'], [
         str(article.id),
     ])
Esempio n. 56
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
Esempio n. 57
0
 def test_associates_the_citation_list_to_the_request_object(self):
     # Setup
     issue = IssueFactory.create(journal=self.journal)
     article = ArticleFactory.create(issue=issue)
     request = self.factory.get('/')
     request.user = AnonymousUser()
     middleware = SessionMiddleware()
     middleware.process_request(request)
     citation_list = SavedCitationList(request)
     citation_list.add(article)
     citation_list.save()
     middleware = SavedCitationListMiddleware()
     # Run
     middleware.process_request(request)
     # Check
     self.assertEqual(list(request.saved_citations), [
         str(article.id),
     ])
Esempio n. 58
0
 def test_can_transform_article_xml_to_html(self, mock_has_coverpage,
                                            mock_ds, mock_xsd300):
     # Setup
     with open(FIXTURE_ROOT + '/article.xml', mode='r') as fp:
         xml = fp.read()
     mock_xsd300.content.serialize = unittest.mock.MagicMock(
         return_value=xml)
     issue = IssueFactory.create(journal=self.journal,
                                 date_published=dt.datetime.now(),
                                 localidentifier='test')
     article = ArticleFactory.create(issue=issue)
     # Run
     ret = render_article(Context({}), article)
     # Check
     self.assertTrue(ret is not None)
     self.assertTrue(
         ret.startswith(
             '<div xmlns:v="variables-node" class="article-wrapper">'))
Esempio n. 59
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)
Esempio n. 60
0
 def test_can_associate_the_article_to_the_registered_users(self):
     # Setup
     issue = IssueFactory.create(journal=self.journal)
     article = ArticleFactory.create(issue=issue)
     request = self.factory.get('/')
     request.user = self.user
     middleware = SessionMiddleware()
     middleware.process_request(request)
     citation_list = SavedCitationList(request)
     citation_list.add(article)
     # Run
     citation_list.save()
     # Check
     self.assertEqual(DBSavedCitationList.objects.count(), 1)
     db_citation_list = DBSavedCitationList.objects.first()
     self.assertEqual(db_citation_list.user, self.user)
     self.assertEqual(list(db_citation_list.documents.all()), [
         article,
     ])