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")
def setUp(self): super(TestRegistrationCreate, self).setUp() ensure_schemas() self.schema = MetaSchema.find_one( Q('name', 'eq', 'Replication Recipe (Brandt et al., 2013): Post-Completion') & Q('schema_version', 'eq', LATEST_SCHEMA_VERSION)) self.draft_registration = DraftRegistrationFactory( initiator=self.user, registration_schema=self.schema, branched_from=self.public_project, registration_metadata={ 'item29': { 'value': 'Yes' }, 'item33': { 'value': 'success' } }) self.url = '/{}nodes/{}/registrations/'.format(API_BASE, self.public_project._id) self.payload = { "data": { "type": "registrations", "attributes": { "draft_registration": self.draft_registration._id, "registration_choice": "immediate" } } }