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


Python DraftRegistrationFactory.registration_metadata方法代码示例

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


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

示例1: test_required_third_level_questions_must_be_answered_on_draft

# 需要导入模块: from osf_tests.factories import DraftRegistrationFactory [as 别名]
# 或者: from osf_tests.factories.DraftRegistrationFactory import registration_metadata [as 别名]
    def test_required_third_level_questions_must_be_answered_on_draft(self, mock_enqueue):
        prereg_schema = MetaSchema.find_one(
            Q('name', 'eq', 'Prereg Challenge') &
            Q('schema_version', 'eq', LATEST_SCHEMA_VERSION)
        )

        prereg_draft_registration = DraftRegistrationFactory(
            initiator=self.user,
            registration_schema=prereg_schema,
            branched_from=self.public_project
        )

        registration_metadata = self.prereg_metadata(prereg_draft_registration)
        registration_metadata['q11'] = {'value': {"question": {}}}

        prereg_draft_registration.registration_metadata = registration_metadata
        prereg_draft_registration.save()

        payload = {
            "data": {
                "type": "registrations",
                "attributes": {
                    "registration_choice": "immediate",
                    "draft_registration": prereg_draft_registration._id,
                    }
                }
        }

        res = self.app.post_json_api(self.url, payload, auth=self.user.auth, expect_errors=True)
        assert_equal(res.status_code, 400)
        assert_equal(res.json['errors'][0]['detail'], "'value' is a required property")
开发者ID:adlius,项目名称:osf.io,代码行数:33,代码来源:test_registration_list.py

示例2: test_required_third_level_questions_must_be_answered_on_draft

# 需要导入模块: from osf_tests.factories import DraftRegistrationFactory [as 别名]
# 或者: from osf_tests.factories.DraftRegistrationFactory import registration_metadata [as 别名]
    def test_required_third_level_questions_must_be_answered_on_draft(
            self, mock_enqueue, app, user, project_public,
            prereg_metadata, url_registrations):
        prereg_schema = MetaSchema.objects.get(
            name='Prereg Challenge',
            schema_version=LATEST_SCHEMA_VERSION)

        prereg_draft_registration = DraftRegistrationFactory(
            initiator=user,
            registration_schema=prereg_schema,
            branched_from=project_public
        )

        registration_metadata = prereg_metadata(prereg_draft_registration)
        registration_metadata['q11'] = {'value': {"question": {}}}

        prereg_draft_registration.registration_metadata = registration_metadata
        prereg_draft_registration.save()

        payload = {
            'data': {
                'type': 'registrations',
                'attributes': {
                    'registration_choice': 'immediate',
                    'draft_registration': prereg_draft_registration._id,
                }
            }
        }

        res = app.post_json_api(
            url_registrations, payload,
            auth=user.auth,
            expect_errors=True)
        assert res.status_code == 400
        assert res.json['errors'][0]['detail'] == '\'value\' is a required property'
开发者ID:icereval,项目名称:osf.io,代码行数:37,代码来源:test_registration_list.py

示例3: test_required_metaschema_questions_not_required_on_post

# 需要导入模块: from osf_tests.factories import DraftRegistrationFactory [as 别名]
# 或者: from osf_tests.factories.DraftRegistrationFactory import registration_metadata [as 别名]
    def test_required_metaschema_questions_not_required_on_post(self):
        prereg_schema = MetaSchema.find_one(
            Q('name', 'eq', 'Prereg Challenge') &
            Q('schema_version', 'eq', LATEST_SCHEMA_VERSION)
        )

        prereg_draft_registration = DraftRegistrationFactory(
            initiator=self.user,
            registration_schema=prereg_schema,
            branched_from=self.public_project
        )

        url = '/{}nodes/{}/draft_registrations/?embed=initiator&embed=branched_from'.format(API_BASE, self.public_project._id)

        registration_metadata = self.prereg_metadata(prereg_draft_registration)
        del registration_metadata['q1']
        prereg_draft_registration.registration_metadata = registration_metadata
        prereg_draft_registration.save()

        payload = {
            "data": {
                "type": "draft_registrations",
                "attributes": {
                    "registration_supplement": prereg_schema._id,
                    "registration_metadata": registration_metadata
                }
            }
        }
        res = self.app.post_json_api(url, payload, auth=self.user.auth, expect_errors=True)
        assert_equal(res.status_code, 201)
        data = res.json['data']
        assert_equal(res.json['data']['attributes']['registration_metadata']['q2']['value'], 'Test response')
        assert_equal(data['attributes']['registration_supplement'], prereg_schema._id)
        assert_equal(data['embeds']['branched_from']['data']['id'], self.public_project._id)
        assert_equal(data['embeds']['initiator']['data']['id'], self.user._id)
开发者ID:adlius,项目名称:osf.io,代码行数:37,代码来源:test_node_draft_registration_list.py

示例4: test_required_metaschema_questions_not_required_on_post

# 需要导入模块: from osf_tests.factories import DraftRegistrationFactory [as 别名]
# 或者: from osf_tests.factories.DraftRegistrationFactory import registration_metadata [as 别名]
    def test_required_metaschema_questions_not_required_on_post(
            self, app, user, provider, project_public, prereg_metadata):
        prereg_schema = RegistrationSchema.objects.get(
            name='Prereg Challenge',
            schema_version=LATEST_SCHEMA_VERSION)

        prereg_draft_registration = DraftRegistrationFactory(
            initiator=user,
            registration_schema=prereg_schema,
            branched_from=project_public
        )

        url = '/{}nodes/{}/draft_registrations/?embed=initiator&embed=branched_from'.format(
            API_BASE, project_public._id)

        registration_metadata = prereg_metadata(prereg_draft_registration)
        del registration_metadata['q1']
        prereg_draft_registration.registration_metadata = registration_metadata
        prereg_draft_registration.save()

        payload = {
            'data': {
                'type': 'draft_registrations',
                'attributes': {
                    'registration_metadata': registration_metadata
                },
                'relationships': {
                    'registration_schema': {
                        'data': {
                            'type': 'registration_schema',
                            'id': prereg_schema._id
                        }
                    },
                    'provider': {
                        'data': {
                            'type': 'registration-providers',
                            'id': provider._id,
                        }
                    }
                }
            }
        }
        res = app.post_json_api(
            url, payload, auth=user.auth,
            expect_errors=True)
        assert res.status_code == 201
        data = res.json['data']
        assert res.json['data']['attributes']['registration_metadata']['q2']['value'] == 'Test response'
        assert prereg_schema._id in data['relationships']['registration_schema']['links']['related']['href']
        assert data['embeds']['branched_from']['data']['id'] == project_public._id
        assert data['embeds']['initiator']['data']['id'] == user._id
开发者ID:aaxelb,项目名称:osf.io,代码行数:53,代码来源:test_node_draft_registration_list.py


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