當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。