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


Python ApplicationFixtureFactory.make_application_source方法代码示例

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


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

示例1: test_03_classification_required

# 需要导入模块: from doajtest.fixtures import ApplicationFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.ApplicationFixtureFactory import make_application_source [as 别名]
    def test_03_classification_required(self):
        # Check we can accept an application with a subject classification present
        ready_application = models.Suggestion(**ApplicationFixtureFactory.make_application_source())
        ready_application.set_application_status(constants.APPLICATION_STATUS_READY)

        fc = formcontext.ApplicationFormFactory.get_form_context(role='admin', source=ready_application)

        # Make changes to the application status via the form, check it validates
        fc.form.application_status.data = constants.APPLICATION_STATUS_ACCEPTED

        assert fc.validate()

        # Without a subject classification, we should not be able to set the status to 'accepted'
        no_class_application = models.Suggestion(**ApplicationFixtureFactory.make_application_source())
        del no_class_application.data['bibjson']['subject']
        fc = formcontext.ApplicationFormFactory.get_form_context(role='admin', source=no_class_application)
        # Make changes to the application status via the form
        assert fc.source.bibjson().subjects() == []
        fc.form.application_status.data = constants.APPLICATION_STATUS_ACCEPTED

        assert not fc.validate()

        # However, we should be able to set it to a different status rather than 'accepted'
        fc.form.application_status.data = constants.APPLICATION_STATUS_IN_PROGRESS

        assert fc.validate()
开发者ID:DOAJ,项目名称:doaj,代码行数:28,代码来源:test_fc_maned_app_review.py

示例2: test_02_classification_required

# 需要导入模块: from doajtest.fixtures import ApplicationFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.ApplicationFixtureFactory import make_application_source [as 别名]
    def test_02_classification_required(self):
        # Check we can mark an application 'completed' with a subject classification present
        in_progress_application = models.Suggestion(**ApplicationFixtureFactory.make_application_source())
        in_progress_application.set_application_status(constants.APPLICATION_STATUS_IN_PROGRESS)

        fc = formcontext.ApplicationFormFactory.get_form_context(role='associate_editor', source=in_progress_application)

        # Make changes to the application status via the form, check it validates
        fc.form.application_status.data = constants.APPLICATION_STATUS_COMPLETED

        assert fc.validate()

        # Without a subject classification, we should not be able to set the status to 'completed'
        no_class_application = models.Suggestion(**ApplicationFixtureFactory.make_application_source())
        del no_class_application.data['bibjson']['subject']
        fc = formcontext.ApplicationFormFactory.get_form_context(role='associate_editor', source=no_class_application)
        # Make changes to the application status via the form
        assert fc.source.bibjson().subjects() == []
        fc.form.application_status.data = constants.APPLICATION_STATUS_COMPLETED

        assert not fc.validate()

        # However, we should be able to set it to a different status rather than 'completed'
        fc.form.application_status.data = constants.APPLICATION_STATUS_PENDING

        assert fc.validate()
开发者ID:DOAJ,项目名称:doaj,代码行数:28,代码来源:test_fc_assed_app_review.py

示例3: test_08_publisher_result_filter

# 需要导入模块: from doajtest.fixtures import ApplicationFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.ApplicationFixtureFactory import make_application_source [as 别名]
    def test_08_publisher_result_filter(self):
        apsrc_admin = ApplicationFixtureFactory.make_application_source()['admin']
        # Not all of these properties are applicable to applications, but these test objects are not applications:
        # they are made-up admin sections designed solely to test whether the filter lets the right keys through.
        # We just use applications as a base to construct them.
        apsrc_admin['ticked'] = True
        apsrc_admin['in_doaj'] = True
        apsrc_admin['related_applications'] = [1,2,3]
        apsrc_admin['current_application'] = 'abcde'

        allowed = ["ticked", "seal", "in_doaj", "related_applications", "current_application", "current_journal", "application_status"]
        forbidden = ['notes', 'contact', 'editor_group', 'editor', 'related_journal']

        res = {
            "hits": {
                "hits": [
                    { "_type": "article", "_source": { "admin": deepcopy(apsrc_admin), "bibjson": {}}},
                    { "_type": "article", "_source": { "admin": deepcopy(apsrc_admin), "bibjson": {}}},
                    { "_type": "article", "_source": { "admin": deepcopy(apsrc_admin), "bibjson": {}}}
                ],
                "total": 3
            }
        }

        newres = query_filters.publisher_result_filter(res)

        for n, r in enumerate(newres['hits']['hits']):
            for allowed_k in allowed:
                assert allowed_k in r['_source']['admin'], \
                    '{} key not found in result {}, but it is allowed and should have been left intact by the filter'.format(allowed_k, n)
            for forbidden_k in forbidden:
                assert forbidden_k not in r['_source']['admin'], \
                    '{} key was found in result {}, but it is forbidden and should have been stripped out by the filter'.format(forbidden_k, n)
开发者ID:DOAJ,项目名称:doaj,代码行数:35,代码来源:test_query_filters.py

示例4: create_edit_cases

# 需要导入模块: from doajtest.fixtures import ApplicationFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.ApplicationFixtureFactory import make_application_source [as 别名]
def create_edit_cases():
    application_source = ApplicationFixtureFactory.make_application_source()
    account_source = AccountFixtureFactory.make_publisher_source()

    editable_application = Suggestion(**application_source)
    editable_application.set_application_status(constants.APPLICATION_STATUS_UPDATE_REQUEST)

    non_editable_application = Suggestion(**application_source)
    non_editable_application.set_application_status(constants.APPLICATION_STATUS_READY)

    owner_account = Account(**deepcopy(account_source))
    owner_account.set_id(editable_application.owner)

    non_owner_publisher = Account(**deepcopy(account_source))

    non_publisher = Account(**deepcopy(account_source))
    non_publisher.remove_role("publisher")

    admin = Account(**deepcopy(account_source))
    admin.add_role("admin")

    return [
        param("no_app_no_account", None, None, raises=exceptions.ArgumentException),
        param("no_app_with_account", None, owner_account, raises=exceptions.ArgumentException),
        param("app_no_account", editable_application, None, raises=exceptions.ArgumentException),
        param("editable_app_owning_account", editable_application, owner_account, expected=True),
        param("editable_app_nonowning_account", editable_application, non_owner_publisher, raises=exceptions.AuthoriseException),
        param("editable_app_non_publisher_account", editable_application, non_publisher, raises=exceptions.AuthoriseException),
        param("editable_app_admin_account", editable_application, admin, expected=True),
        param("non_editable_app_owning_account", non_editable_application, owner_account, raises=exceptions.AuthoriseException),
        param("non_editable_app_nonowning_account", non_editable_application, non_owner_publisher, raises=exceptions.AuthoriseException),
        param("non_editable_app_non_publisher_account", non_editable_application, non_publisher, raises=exceptions.AuthoriseException),
        param("non_editable_app_admin_account", non_editable_application, admin, expected=True)
    ]
开发者ID:DOAJ,项目名称:doaj,代码行数:36,代码来源:test_bll_authorisations.py

示例5: test_06_make_journal

# 需要导入模块: from doajtest.fixtures import ApplicationFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.ApplicationFixtureFactory import make_application_source [as 别名]
    def test_06_make_journal(self):
        s = models.Suggestion(**ApplicationFixtureFactory.make_application_source())
        j = s.make_journal()

        assert j.id != s.id
        assert "suggestion" not in j.data
        assert j.data.get("bibjson", {}).get("active")
开发者ID:jbarnsby,项目名称:doaj,代码行数:9,代码来源:test_models.py

示例6: test_14_make_journal_from_reapp

# 需要导入模块: from doajtest.fixtures import ApplicationFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.ApplicationFixtureFactory import make_application_source [as 别名]
    def test_14_make_journal_from_reapp(self):
        # with history
        j = models.Journal()
        j.set_id("1234567")
        j.set_created("2001-01-01T00:00:00Z")
        j.add_history({"title" : "old title"})
        j.save()

        s = models.Suggestion(**ApplicationFixtureFactory.make_application_source())
        s.set_current_journal("1234567")

        time.sleep(1)
        j = s.make_journal()
        j.save()

        assert j.id == "1234567"
        assert "suggestion" not in j.data
        assert j.last_reapplication is not None
        assert j.data.get("bibjson", {}).get("active")
        assert j.current_application is None
        assert j.data.get("admin", {}).get("current_journal") is None
        assert j.created_date == "2001-01-01T00:00:00Z"
        assert j.get_history_raw()[0].get("bibjson", {}).get("title") == "old title"

        # without history
        j = models.Journal()
        j.set_id("1234567")
        j.set_created("2001-01-01T00:00:00Z")
        j.save()

        s = models.Suggestion(**ApplicationFixtureFactory.make_application_source())
        s.set_current_journal("1234567")

        time.sleep(1)
        j = s.make_journal()
        j.save()

        assert j.id == "1234567"
        assert "suggestion" not in j.data
        assert j.last_reapplication is not None
        assert j.data.get("bibjson", {}).get("active")
        assert j.current_application is None
        assert j.data.get("admin", {}).get("current_journal") is None
        assert j.created_date == "2001-01-01T00:00:00Z"
        assert len(j.history()) == 0
开发者ID:jbarnsby,项目名称:doaj,代码行数:47,代码来源:test_reapplication.py

示例7: test_32_application_all_by_related_journal

# 需要导入模块: from doajtest.fixtures import ApplicationFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.ApplicationFixtureFactory import make_application_source [as 别名]
    def test_32_application_all_by_related_journal(self):
        j = models.Journal()
        j.set_id(j.makeid())

        app1 = models.Suggestion(**ApplicationFixtureFactory.make_application_source())
        app1.set_id(app1.makeid())
        app1.set_related_journal(j.id)
        app1.set_created("1970-01-01T00:00:00Z")
        app1.save()

        app2 = models.Suggestion(**ApplicationFixtureFactory.make_application_source())
        app2.set_id(app2.makeid())
        app2.set_related_journal(j.id)
        app2.set_created("1971-01-01T00:00:00Z")
        app2.save(blocking=True)

        # check that we find all the applications when we search, and that they're in the right order
        all = models.Suggestion.find_all_by_related_journal(j.id)
        assert len(all) == 2
        assert all[0].id == app1.id
        assert all[1].id == app2.id
开发者ID:DOAJ,项目名称:doaj,代码行数:23,代码来源:test_models.py

示例8: test_08_sync_owners

# 需要导入模块: from doajtest.fixtures import ApplicationFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.ApplicationFixtureFactory import make_application_source [as 别名]
    def test_08_sync_owners(self):
        # suggestion with no current_journal
        s = models.Suggestion(**ApplicationFixtureFactory.make_application_source())
        s.save()

        models.Suggestion.refresh()
        s = models.Suggestion.pull(s.id)
        assert s is not None

        # journal with no current_application
        j = models.Journal(**JournalFixtureFactory.make_journal_source())
        j.save()

        models.Journal.refresh()
        j = models.Journal.pull(j.id)
        assert j is not None

        # suggestion with erroneous current_journal
        s.set_current_journal("asdklfjsadjhflasdfoasf")
        s.save()

        models.Suggestion.refresh()
        s = models.Suggestion.pull(s.id)
        assert s is not None

        # journal with erroneous current_application
        j.set_current_application("kjwfuiwqhu220952gw")
        j.save()

        models.Journal.refresh()
        j = models.Journal.pull(j.id)
        assert j is not None

        # suggestion with journal
        s.set_owner("my_new_owner")
        s.set_current_journal(j.id)
        s.save()

        models.Journal.refresh()
        j = models.Journal.pull(j.id)
        assert j.owner == "my_new_owner"

        # journal with suggestion
        j.set_owner("another_new_owner")
        j.set_current_application(s.id)
        j.save()

        models.Suggestion.refresh()
        s = models.Suggestion.pull(s.id)
        assert s.owner == "another_new_owner"
开发者ID:DOAJ,项目名称:doaj,代码行数:52,代码来源:test_models.py

示例9: test_31_application_latest_by_current_journal

# 需要导入模块: from doajtest.fixtures import ApplicationFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.ApplicationFixtureFactory import make_application_source [as 别名]
    def test_31_application_latest_by_current_journal(self):
        j = models.Journal()
        j.set_id(j.makeid())

        app1 = models.Suggestion(**ApplicationFixtureFactory.make_application_source())
        app1.set_id(app1.makeid())
        app1.set_current_journal(j.id)
        app1.set_created("1970-01-01T00:00:00Z")
        app1.save()

        app2 = models.Suggestion(**ApplicationFixtureFactory.make_application_source())
        app2.set_id(app2.makeid())
        app2.set_current_journal(j.id)
        app2.set_created("1971-01-01T00:00:00Z")
        app2.save(blocking=True)

        # check that we find the right application when we search
        app3 = models.Suggestion.find_latest_by_current_journal(j.id)
        assert app3 is not None
        assert app3.id == app2.id

        # make sure we get a None response when there's no application
        app0 = models.Suggestion.find_latest_by_current_journal("whatever")
        assert app0 is None
开发者ID:DOAJ,项目名称:doaj,代码行数:26,代码来源:test_models.py

示例10: test_06_retrieve_application_success

# 需要导入模块: from doajtest.fixtures import ApplicationFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.ApplicationFixtureFactory import make_application_source [as 别名]
    def test_06_retrieve_application_success(self):
        # set up all the bits we need
        data = ApplicationFixtureFactory.make_application_source()
        ap = models.Suggestion(**data)
        ap.save()
        time.sleep(2)

        account = models.Account()
        account.set_id(ap.owner)
        account.set_name("Tester")
        account.set_email("[email protected]")

        # call retrieve on the object
        a = ApplicationsCrudApi.retrieve(ap.id, account)

        # check that we got back the object we expected
        assert isinstance(a, OutgoingApplication)
        assert a.id == ap.id
开发者ID:DOAJ,项目名称:doaj,代码行数:20,代码来源:test_api_crud_application.py

示例11: load_application_cases

# 需要导入模块: from doajtest.fixtures import ApplicationFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.ApplicationFixtureFactory import make_application_source [as 别名]
def load_application_cases():
    account = Account(**AccountFixtureFactory.make_publisher_source())
    account.set_id(account.makeid())

    application = Suggestion(**ApplicationFixtureFactory.make_application_source())
    application.makeid()

    wrong_id = uuid.uuid4()

    return [
        param("a_id_acc_lock", application, application.id, account, True, raises=lock.Locked),
        param("a_id_acc_nolock", application, application.id, account, False),
        param("a_id_noacc_nolock", application, application.id, None, False),
        param("a_noid_noacc_nolock", application, None, None, False, raises=exceptions.ArgumentException),
        param("a_wid_noacc_nolock", application, wrong_id, None, False),
        param("noa_id_noacc_nolock", None, application.id, None, False),
        param("noa_noid_noacc_nolock", None, None, None, False, raises=exceptions.ArgumentException)
    ]
开发者ID:DOAJ,项目名称:doaj,代码行数:20,代码来源:test_bll_getters.py

示例12: test_05_outgoing_application_do

# 需要导入模块: from doajtest.fixtures import ApplicationFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.ApplicationFixtureFactory import make_application_source [as 别名]
    def test_05_outgoing_application_do(self):
        # make a blank one
        oa = OutgoingApplication()

        # make one from an incoming application model fixture
        data = ApplicationFixtureFactory.make_application_source()
        ap = models.Suggestion(**data)
        oa = OutgoingApplication.from_model(ap)

        # check that it does not contain information that it shouldn't
        assert oa.data.get("index") is None
        assert oa.data.get("history") is None
        assert oa.data.get("admin", {}).get("notes") is None
        assert oa.data.get("admin", {}).get("editor_group") is None
        assert oa.data.get("admin", {}).get("editor") is None
        assert oa.data.get("admin", {}).get("seal") is None
        assert oa.data.get("admin", {}).get("related_journal") is None

        # check that it does contain admin information that it should
        assert oa.data.get("admin", {}).get("current_journal") is not None
开发者ID:DOAJ,项目名称:doaj,代码行数:22,代码来源:test_api_crud_application.py

示例13: test_04_maned_review_continuations

# 需要导入模块: from doajtest.fixtures import ApplicationFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.ApplicationFixtureFactory import make_application_source [as 别名]
    def test_04_maned_review_continuations(self):
        # construct it from form data (with a known source)
        fc = formcontext.ApplicationFormFactory.get_form_context(
            role='admin',
            form_data=MultiDict(APPLICATION_FORM),
            source=models.Suggestion(**ApplicationFixtureFactory.make_application_source()))

        # check the form has the continuations data
        assert fc.form.replaces.data == ["1111-1111"]
        assert fc.form.is_replaced_by.data == ["2222-2222"]
        assert fc.form.discontinued_date.data == "2001-01-01"

        # run the crosswalk, don't test it at all in this test
        fc.form2target()
        # patch the target with data from the source
        fc.patch_target()

        # ensure the model has the continuations data
        assert fc.target.bibjson().replaces == ["1111-1111"]
        assert fc.target.bibjson().is_replaced_by == ["2222-2222"]
        assert fc.target.bibjson().discontinued_date == "2001-01-01"
开发者ID:DOAJ,项目名称:doaj,代码行数:23,代码来源:test_fc_maned_app_review.py

示例14: test_03_view_application

# 需要导入模块: from doajtest.fixtures import ApplicationFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.ApplicationFixtureFactory import make_application_source [as 别名]
    def test_03_view_application(self, name, account_type, role, owner, application_type, raises=None, returns=None, auth_reason=None):
        # set up the objects
        application = None
        if application_type == "exists":
            application = Suggestion(**ApplicationFixtureFactory.make_application_source())

        account = None
        if account_type == "exists":
            if role == "none":
                account = Account(**AccountFixtureFactory.make_publisher_source())
                account.remove_role("publisher")
            elif role == "publisher":
                account = Account(**AccountFixtureFactory.make_publisher_source())
            elif role == "admin":
                account = Account(**AccountFixtureFactory.make_managing_editor_source())

            if owner == "yes":
                application.set_owner(account.id)


        svc = DOAJ.authorisationService()
        if raises is not None and raises != "":
            exception = None
            with self.assertRaises(EXCEPTIONS[raises]):
                try:
                    svc.can_view_application(account, application)
                except Exception as e:
                    exception = e
                    raise e
            if raises == "AuthoriseException":
                if auth_reason == "not_owner":
                    assert exception.reason == exception.NOT_OWNER
                elif auth_reason == "wrong_role":
                    assert exception.reason == exception.WRONG_ROLE

        elif returns is not None:
            expected = returns == "true"
            assert svc.can_view_application(account, application) is expected
        else:
            assert False, "Specify either raises or returns"
开发者ID:DOAJ,项目名称:doaj,代码行数:42,代码来源:test_bll_authorisations.py

示例15: test_07_retrieve_application_fail

# 需要导入模块: from doajtest.fixtures import ApplicationFixtureFactory [as 别名]
# 或者: from doajtest.fixtures.ApplicationFixtureFactory import make_application_source [as 别名]
    def test_07_retrieve_application_fail(self):
        # set up all the bits we need
        data = ApplicationFixtureFactory.make_application_source()
        ap = models.Suggestion(**data)
        ap.save()
        time.sleep(2)

        # no user
        with self.assertRaises(Api401Error):
            a = ApplicationsCrudApi.retrieve(ap.id, None)

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

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


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