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


Python JournalFixtureFactory.make_journal_source方法代码示例

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


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

示例1: test_03_create_articles_fail

# 需要导入模块: from doajtest.fixtures import JournalFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.JournalFixtureFactory import make_journal_source [as 别名]
    def test_03_create_articles_fail(self):
        # if the account is dud
        with self.assertRaises(Api401Error):
            data = ArticleFixtureFactory.make_incoming_api_article()
            dataset = [data] * 10
            ids = ArticlesBulkApi.create(dataset, None)

        # check that the index is empty, as none of them should have been made
        all = [x for x in models.Article.iterall()]
        assert len(all) == 0

        # if the data is bust
        with self.assertRaises(Api400Error):
            account = models.Account()
            account.set_id("test")
            account.set_name("Tester")
            account.set_email("[email protected]")
            # add a journal to the account
            journal = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True))
            journal.set_owner(account.id)
            journal.save()
            time.sleep(1)
            dataset = dataset[:5] + [{"some" : {"junk" : "data"}}] + dataset[5:]
            ids = ArticlesBulkApi.create(dataset, account)

        # check that the index is empty, as none of them should have been made
        all = [x for x in models.Article.iterall()]
        assert len(all) == 0
开发者ID:DOAJ,项目名称:doaj,代码行数:30,代码来源:test_api_bulk_article.py

示例2: test_02_create_duplicate_articles

# 需要导入模块: from doajtest.fixtures import JournalFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.JournalFixtureFactory import make_journal_source [as 别名]
    def test_02_create_duplicate_articles(self):
        # set up all the bits we need - 10 articles
        data = ArticleFixtureFactory.make_incoming_api_article()
        dataset = [data] * 10

        # create an account that we'll do the create as
        account = models.Account()
        account.set_id("test")
        account.set_name("Tester")
        account.set_email("[email protected]")

        # add a journal to the account
        journal = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True))
        journal.set_owner(account.id)
        journal.save()

        time.sleep(2)

        # call create on the object (which will save it to the index)
        with self.assertRaises(Api400Error):
            ids = ArticlesBulkApi.create(dataset, account)

        time.sleep(2)

        with self.assertRaises(ESMappingMissingError):
            all_articles = models.Article.all()
开发者ID:DOAJ,项目名称:doaj,代码行数:28,代码来源:test_api_bulk_article.py

示例3: test_11_delete_article_fail

# 需要导入模块: from doajtest.fixtures import JournalFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.JournalFixtureFactory import make_journal_source [as 别名]
    def test_11_delete_article_fail(self):
        # set up all the bits we need
        account = models.Account()
        account.set_id('test')
        account.set_name("Tester")
        account.set_email("[email protected]")
        journal = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True))
        journal.set_owner(account.id)
        journal.save()
        time.sleep(1)

        data = ArticleFixtureFactory.make_article_source()

        # call create on the object (which will save it to the index)
        a = ArticlesCrudApi.create(data, account)

        # let the index catch up
        time.sleep(1)

        # call delete on the object in various context that will fail

        # without an account
        with self.assertRaises(Api401Error):
            ArticlesCrudApi.delete(a.id, None)

        # with the wrong account
        account.set_id("other")
        with self.assertRaises(Api404Error):
            ArticlesCrudApi.delete(a.id, account)

        # on the wrong id
        account.set_id("test")
        with self.assertRaises(Api404Error):
            ArticlesCrudApi.delete("adfasdfhwefwef", account)
开发者ID:DOAJ,项目名称:doaj,代码行数:36,代码来源:test_api_crud_article.py

示例4: test_06_anonymise_admin_empty_notes

# 需要导入模块: from doajtest.fixtures import JournalFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.JournalFixtureFactory import make_journal_source [as 别名]
    def test_06_anonymise_admin_empty_notes(self):
        journal_src = JournalFixtureFactory.make_journal_source()

        journal_src['admin'] = {
            'owner': 'testuser',
            'editor': 'testeditor',
            'contact': [{
                'email': '[email protected]',
                'name': 'Tester Tester'
            }],
            'notes': []
        }

        journal = models.Journal(**journal_src)

        with freeze_time("2017-02-23"):
            ar = anon_export._anonymise_admin(journal)

        assert ar.data['admin'] == {
            'owner': 'testuser',
            'editor': 'testeditor',
            'contact': [{
                'email': '5[email protected]example.com',
                'name': 'Ryan Gallagher'
            }],
            'notes': []
        }, ar['admin']
开发者ID:DOAJ,项目名称:doaj,代码行数:29,代码来源:test_anon.py

示例5: test_02_retrieve_public_journal_success

# 需要导入模块: from doajtest.fixtures import JournalFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.JournalFixtureFactory import make_journal_source [as 别名]
    def test_02_retrieve_public_journal_success(self):
        # set up all the bits we need
        data = JournalFixtureFactory.make_journal_source(in_doaj=True, include_obsolete_fields=True)
        j = models.Journal(**data)
        j.save()
        time.sleep(2)
        
        a = JournalsCrudApi.retrieve(j.id, account=None)
        # check that we got back the object we expected
        assert isinstance(a, OutgoingJournal)
        assert a.id == j.id
        
        # it should also work if we're logged in with the owner or another user
        # owner first
        account = models.Account()
        account.set_id(j.owner)
        account.set_name("Tester")
        account.set_email("[email protected]")
        
        a = JournalsCrudApi.retrieve(j.id, account)

        assert isinstance(a, OutgoingJournal)
        assert a.id == j.id
        
        # try with another account
        not_owner = models.Account()
        not_owner.set_id("asdklfjaioefwe")
        a = JournalsCrudApi.retrieve(j.id, not_owner)
        assert isinstance(a, OutgoingJournal)
        assert a.id == j.id
开发者ID:DOAJ,项目名称:doaj,代码行数:32,代码来源:test_api_crud_journal.py

示例6: test_10_delete_article_success

# 需要导入模块: from doajtest.fixtures import JournalFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.JournalFixtureFactory import make_journal_source [as 别名]
    def test_10_delete_article_success(self):
        # set up all the bits we need
        account = models.Account()
        account.set_id('test')
        account.set_name("Tester")
        account.set_email("[email protected]")
        journal = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True))
        journal.set_owner(account.id)
        journal.save()
        time.sleep(1)

        data = ArticleFixtureFactory.make_article_source()

        # call create on the object (which will save it to the index)
        a = ArticlesCrudApi.create(data, account)

        # let the index catch up
        time.sleep(1)

        # now delete it
        ArticlesCrudApi.delete(a.id, account)

        # let the index catch up
        time.sleep(1)

        ap = models.Article.pull(a.id)
        assert ap is None
开发者ID:DOAJ,项目名称:doaj,代码行数:29,代码来源:test_api_crud_article.py

示例7: get_journal

# 需要导入模块: from doajtest.fixtures import JournalFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.JournalFixtureFactory import make_journal_source [as 别名]
    def get_journal(cls, specs):
        journals = []

        for spec in specs:
            source = JournalFixtureFactory.make_journal_source(in_doaj=True)
            j = Journal(**source)
            bj = j.bibjson()
            bj.title = spec.get("title", "Journal Title")
            bj.remove_identifiers()
            if "pissn" in spec:
                bj.add_identifier(bj.P_ISSN, spec.get("pissn"))
            if "eissn" in spec:
                bj.add_identifier(bj.E_ISSN, spec.get("eissn"))
            spec["instance"] = j
            journals.append(spec)

        def mock(self):
            bibjson = self.bibjson()

            # first, get the ISSNs associated with the record
            pissns = bibjson.get_identifiers(bibjson.P_ISSN)
            eissns = bibjson.get_identifiers(bibjson.E_ISSN)

            for j in journals:
                if j["pissn"] in pissns and j["eissn"] in eissns:
                    return j["instance"]

        return mock
开发者ID:DOAJ,项目名称:doaj,代码行数:30,代码来源:model_Article.py

示例8: test_07_retrieve_article_fail

# 需要导入模块: from doajtest.fixtures import JournalFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.JournalFixtureFactory import make_journal_source [as 别名]
    def test_07_retrieve_article_fail(self):
        # set up all the bits we need
        # add a journal to the account
        account = models.Account()
        account.set_id('test')
        account.set_name("Tester")
        account.set_email("[email protected]")
        journal = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True))
        journal.set_owner(account.id)
        journal.save()
        time.sleep(1)

        data = ArticleFixtureFactory.make_article_source()
        data['admin']['in_doaj'] = False
        ap = models.Article(**data)
        ap.save()
        time.sleep(1)

        # should fail when no user and in_doaj is False
        with self.assertRaises(Api401Error):
            a = ArticlesCrudApi.retrieve(ap.id, None)

        # wrong user
        account = models.Account()
        account.set_id("asdklfjaioefwe")
        with self.assertRaises(Api404Error):
            a = ArticlesCrudApi.retrieve(ap.id, account)

        # non-existant article
        account = models.Account()
        account.set_id(ap.id)
        with self.assertRaises(Api404Error):
            a = ArticlesCrudApi.retrieve("ijsidfawefwefw", account)
开发者ID:DOAJ,项目名称:doaj,代码行数:35,代码来源:test_api_crud_article.py

示例9: test_15_create_application_update_request_dryrun

# 需要导入模块: from doajtest.fixtures import JournalFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.JournalFixtureFactory import make_journal_source [as 别名]
    def test_15_create_application_update_request_dryrun(self):
        # set up all the bits we need
        data = ApplicationFixtureFactory.incoming_application()
        account = models.Account()
        account.set_id("test")
        account.set_name("Tester")
        account.set_email("[email protected]")
        account.add_role("publisher")

        journal = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True))
        journal.bibjson().remove_identifiers()
        journal.bibjson().add_identifier(journal.bibjson().E_ISSN, "9999-8888")
        journal.bibjson().add_identifier(journal.bibjson().P_ISSN, "7777-6666")
        journal.bibjson().title = "not changed"
        journal.set_id(data["admin"]["current_journal"])
        journal.set_owner(account.id)
        journal.save(blocking=True)

        # call create on the object, with the dry_run flag set
        a = ApplicationsCrudApi.create(data, account, dry_run=True)

        time.sleep(2)

        # now check that the application index remains empty
        ss = [x for x in models.Suggestion.iterall()]
        assert len(ss) == 0
开发者ID:DOAJ,项目名称:doaj,代码行数:28,代码来源:test_api_crud_application.py

示例10: test_03b_create_update_request_fail

# 需要导入模块: from doajtest.fixtures import JournalFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.JournalFixtureFactory import make_journal_source [as 别名]
    def test_03b_create_update_request_fail(self):
        # update request target not found
        with self.assertRaises(Api404Error):
            data = ApplicationFixtureFactory.incoming_application()
            publisher = models.Account(**AccountFixtureFactory.make_publisher_source())
            try:
                a = ApplicationsCrudApi.create(data, publisher)
            except Api404Error as e:
                raise

        # if a formcontext exception is raised on finalise
        publisher = models.Account(**AccountFixtureFactory.make_publisher_source())
        journal = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True))
        journal.set_id(journal.makeid())
        journal.set_owner(publisher.id)
        journal.save(blocking=True)
        formcontext.FormContext.finalise = mock_finalise_exception
        with self.assertRaises(Api400Error):
            data = ApplicationFixtureFactory.incoming_application()
            data["admin"]["current_journal"] = journal.id

            try:
                a = ApplicationsCrudApi.create(data, publisher)
            except Api400Error as e:
                assert e.message == "test exception"
                raise
        formcontext.FormContext.finalise = self.old_finalise

        # validation fails on the formcontext
        publisher = models.Account(**AccountFixtureFactory.make_publisher_source())
        journal = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True))
        journal.set_id(journal.makeid())
        journal.set_owner(publisher.id)
        journal.save(blocking=True)
        IncomingApplication.custom_validate = mock_custom_validate_always_pass
        with self.assertRaises(Api400Error):
            data = ApplicationFixtureFactory.incoming_application()
            # duff submission charges url should trip the validator
            data["bibjson"]["submission_charges_url"] = "not a url!"
            data["admin"]["current_journal"] = journal.id
            try:
                a = ApplicationsCrudApi.create(data, publisher)
            except Api400Error as e:
                raise
开发者ID:DOAJ,项目名称:doaj,代码行数:46,代码来源:test_api_crud_application.py

示例11: test_13_create_application_update_request_success

# 需要导入模块: from doajtest.fixtures import JournalFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.JournalFixtureFactory import make_journal_source [as 别名]
    def test_13_create_application_update_request_success(self):
        # set up all the bits we need
        data = ApplicationFixtureFactory.incoming_application()
        account = models.Account()
        account.set_id("test")
        account.set_name("Tester")
        account.set_email("[email protected]")
        account.add_role("publisher")
        account.save(blocking=True)

        journal = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True))
        journal.bibjson().remove_identifiers()
        journal.bibjson().add_identifier(journal.bibjson().E_ISSN, "9999-8888")
        journal.bibjson().add_identifier(journal.bibjson().P_ISSN, "7777-6666")
        journal.bibjson().title = "not changed"
        journal.set_id(data["admin"]["current_journal"])
        journal.set_owner(account.id)
        journal.save(blocking=True)

        # call create on the object (which will save it to the index)
        a = ApplicationsCrudApi.create(data, account)

        # check that it got created with the right properties
        assert isinstance(a, models.Suggestion)
        assert a.id != "ignore_me"
        assert a.created_date != "2001-01-01T00:00:00Z"
        assert a.last_updated != "2001-01-01T00:00:00Z"
        assert a.suggester.get("name") == "Tester"           # The suggester should be the owner of the existing journal
        assert a.suggester.get("email") == "[email protected]"
        assert a.owner == "test"
        assert a.suggested_on is not None
        assert a.bibjson().issns() == ["9999-8888", "7777-6666"] or a.bibjson().issns() == ["7777-6666", "9999-8888"]
        assert a.bibjson().title == "not changed"

        # also, because it's a special case, check the archiving_policy
        archiving_policy = a.bibjson().archiving_policy
        assert len(archiving_policy.get("policy")) == 4
        lcount = 0
        scount = 0
        for ap in archiving_policy.get("policy"):
            if isinstance(ap, list):
                lcount += 1
                assert ap[0] in ["A national library", "Other"]
                assert ap[1] in ["Trinity", "A safe place"]
            else:
                scount += 1
        assert lcount == 2
        assert scount == 2
        assert "CLOCKSS" in archiving_policy.get("policy")
        assert "LOCKSS" in archiving_policy.get("policy")

        time.sleep(2)

        s = models.Suggestion.pull(a.id)
        assert s is not None
开发者ID:DOAJ,项目名称:doaj,代码行数:57,代码来源:test_api_crud_application.py

示例12: test_03_toc_uses_both_issns_when_available

# 需要导入模块: from doajtest.fixtures import JournalFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.JournalFixtureFactory import make_journal_source [as 别名]
 def test_03_toc_uses_both_issns_when_available(self):
     j = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True))
     pissn = j.bibjson().first_pissn
     eissn = j.bibjson().first_eissn
     j.set_last_manual_update()
     j.save(blocking=True)
     a = models.Article(**ArticleFixtureFactory.make_article_source(pissn=pissn, eissn=eissn, in_doaj=True))
     a.save(blocking=True)
     with self.app_test.test_client() as t_client:
         response = t_client.get('/toc/{}'.format(j.bibjson().get_preferred_issn()))
         assert response.status_code == 200
         assert 'var toc_issns = ["{pissn}","{eissn}"];'.format(pissn=pissn, eissn=eissn) in response.data
开发者ID:DOAJ,项目名称:doaj,代码行数:14,代码来源:test_toc.py

示例13: test_01_create_articles_success

# 需要导入模块: from doajtest.fixtures import JournalFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.JournalFixtureFactory import make_journal_source [as 别名]
    def test_01_create_articles_success(self):
        def find_dict_in_list(lst, key, value):
            for i, dic in enumerate(lst):
                if dic[key] == value:
                    return i
            return -1

        # set up all the bits we need - 10 articles
        dataset = []
        for i in range(1, 11):
            data = ArticleFixtureFactory.make_incoming_api_article()
            # change the DOI and fulltext URLs to escape duplicate detection
            # and try with multiple articles
            doi_ix = find_dict_in_list(data['bibjson']['identifier'], 'type', 'doi')
            if doi_ix == -1:
                data['bibjson']['identifier'].append({"type" : "doi"})
            data['bibjson']['identifier'][doi_ix]['id'] = '10.0000/SOME.IDENTIFIER.{0}'.format(i)
            
            fulltext_url_ix = find_dict_in_list(data['bibjson']['link'], 'type', 'fulltext')
            if fulltext_url_ix == -1:
                data['bibjson']['link'].append({"type" : "fulltext"})
            data['bibjson']['link'][fulltext_url_ix]['url'] = 'http://www.example.com/article_{0}'.format(i)

            dataset.append(deepcopy(data))

        # create an account that we'll do the create as
        account = models.Account()
        account.set_id("test")
        account.set_name("Tester")
        account.set_email("[email protected]")

        # add a journal to the account
        journal = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True))
        journal.set_owner(account.id)
        journal.save()

        time.sleep(2)

        # call create on the object (which will save it to the index)
        ids = ArticlesBulkApi.create(dataset, account)

        # check that we got the right number of ids back
        assert len(ids) == 10
        assert len(list(set(ids))) == 10, len(list(set(ids)))  # are they actually 10 unique IDs?

        # let the index catch up
        time.sleep(2)

        # check that each id was actually created
        for id in ids:
            s = models.Article.pull(id)
            assert s is not None
开发者ID:DOAJ,项目名称:doaj,代码行数:54,代码来源:test_api_bulk_article.py

示例14: test_03c_update_update_request_fail

# 需要导入模块: from doajtest.fixtures import JournalFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.JournalFixtureFactory import make_journal_source [as 别名]
 def test_03c_update_update_request_fail(self):
     # update request target in disallowed status
     journal = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True))
     journal.set_id(journal.makeid())
     journal.save(blocking=True)
     with self.assertRaises(Api404Error):
         data = ApplicationFixtureFactory.incoming_application()
         data["admin"]["current_journal"] = journal.id
         publisher = models.Account(**AccountFixtureFactory.make_publisher_source())
         try:
             a = ApplicationsCrudApi.create(data, publisher)
         except Api404Error as e:
             raise
开发者ID:DOAJ,项目名称:doaj,代码行数:15,代码来源:test_api_crud_application.py

示例15: test_04_timeout

# 需要导入模块: from doajtest.fixtures import JournalFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.JournalFixtureFactory import make_journal_source [as 别名]
    def test_04_timeout(self):
        source = JournalFixtureFactory.make_journal_source()
        j = models.Journal(**source)
        j.save()

        time.sleep(2)

        after = datetime.utcnow() + timedelta(seconds=2300)

        # set a lock with a longer timout
        l = lock.lock("journal", j.id, "testuser", 2400)

        assert dates.parse(l.expires) > after
开发者ID:DOAJ,项目名称:doaj,代码行数:15,代码来源:test_lock.py


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