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


Python factories.IssueFactory类代码示例

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


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

示例1: test_can_return_all_the_articles_associated_with_the_last_issue_of_a_journal

 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'])
开发者ID:erudit,项目名称:eruditorg,代码行数:34,代码来源:test_feeds.py

示例2: setup

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

示例3: test_returns_only_the_internal_issues

 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)
开发者ID:erudit,项目名称:erudit-core,代码行数:9,代码来源:test_managers.py

示例4: test_knows_that_it_is_in_open_access_if_its_issue_is_in_open_access

 def test_knows_that_it_is_in_open_access_if_its_issue_is_in_open_access(self):
     # Setup
     j1 = JournalFactory.create(open_access=True)
     j2 = JournalFactory.create(open_access=False)
     issue_1 = IssueFactory.create(journal=j1)
     article_1 = ArticleFactory.create(issue=issue_1)
     issue_2 = IssueFactory.create(journal=j2)
     article_2 = ArticleFactory.create(issue=issue_2)
     # Run 1 check
     self.assertTrue(article_1.open_access)
     self.assertFalse(article_2.open_access)
开发者ID:erudit,项目名称:erudit-core,代码行数:11,代码来源:test_models.py

示例5: test_can_return_its_first_issue

 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)
开发者ID:erudit,项目名称:erudit-core,代码行数:11,代码来源:test_models.py

示例6: test_embeds_the_latest_issues_into_the_context

 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, ])
开发者ID:erudit,项目名称:eruditorg,代码行数:11,代码来源:test_views.py

示例7: test_can_return_its_published_issues

    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})
开发者ID:erudit,项目名称:erudit-core,代码行数:12,代码来源:test_models.py

示例8: test_knows_its_editors

    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()
开发者ID:erudit,项目名称:erudit-core,代码行数:12,代码来源:test_models.py

示例9: test_can_mark_issues_as_unpublished

 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)
开发者ID:erudit,项目名称:erudit-core,代码行数:14,代码来源:test_modeladmin.py

示例10: test_can_mark_issues_force_free_access_to_false

 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)
开发者ID:erudit,项目名称:erudit-core,代码行数:14,代码来源:test_modeladmin.py

示例11: test_cannot_grant_access_to_an_article_if_it_is_associated_to_an_institutional_account_that_is_not_not_ongoing

    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())
开发者ID:erudit,项目名称:eruditorg,代码行数:34,代码来源:test_viewmixins.py

示例12: test_cannot_grant_access_to_an_article_if_it_is_associated_to_an_individual_subscription_that_is_not_ongoing

    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())
开发者ID:erudit,项目名称:eruditorg,代码行数:25,代码来源:test_viewmixins.py

示例13: test_can_grant_access_to_an_article_if_it_is_associated_to_an_individual_subscription

    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())
开发者ID:erudit,项目名称:eruditorg,代码行数:28,代码来源:test_viewmixins.py

示例14: test_can_grant_access_to_an_article_has_no_movable_limitation

    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())
开发者ID:erudit,项目名称:eruditorg,代码行数:25,代码来源:test_viewmixins.py

示例15: test_can_retrieve_the_first_page_of_the_pdf_of_existing_articles

    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)
开发者ID:erudit,项目名称:eruditorg,代码行数:31,代码来源:test_views.py


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