def test_update_invalid_duplicate_standard_recordattr(self):
     metadata_json_attr_map1 = ckanext_factories.MetadataJSONAttrMap(
         json_path='/c/d', record_attr='url')
     metadata_json_attr_map2 = ckanext_factories.MetadataJSONAttrMap(
         metadata_standard_id=metadata_json_attr_map1[
             'metadata_standard_id'])
     input_dict = {
         'id': metadata_json_attr_map1['id'],
         'record_attr': metadata_json_attr_map2['record_attr'],
     }
     result, obj = self.test_action('metadata_json_attr_map_update',
                                    should_error=True,
                                    **input_dict)
     assert_error(result, 'record_attr', 'Unique constraint violation')
 def test_update_invalid_record_attr(self):
     metadata_json_attr_map = ckanext_factories.MetadataJSONAttrMap()
     result, obj = self.test_action('metadata_json_attr_map_update',
                                    should_error=True,
                                    id=metadata_json_attr_map['id'],
                                    record_attr='owner_org')
     assert_error(result, 'record_attr', 'The specified key cannot be used')
 def test_update_invalid_bad_json_path(self):
     metadata_json_attr_map = ckanext_factories.MetadataJSONAttrMap()
     result, obj = self.test_action('metadata_json_attr_map_update',
                                    should_error=True,
                                    id=metadata_json_attr_map['id'],
                                    json_path='foo')
     assert_error(result, 'json_path', 'Invalid JSON pointer')
 def test_update_invalid_missing_params(self):
     metadata_json_attr_map = ckanext_factories.MetadataJSONAttrMap()
     result, obj = self.test_action('metadata_json_attr_map_update',
                                    should_error=True,
                                    id=metadata_json_attr_map['id'])
     assert_error(result, 'json_path', 'Missing parameter')
     assert_error(result, 'record_attr', 'Missing parameter')
     assert_error(result, 'is_key', 'Missing parameter')
 def test_create_invalid_duplicate_standard_recordattr(self):
     metadata_json_attr_map = ckanext_factories.MetadataJSONAttrMap()
     input_dict = {
         'record_attr': metadata_json_attr_map['record_attr'],
         'metadata_standard_id':
         metadata_json_attr_map['metadata_standard_id'],
     }
     result, obj = self.test_action('metadata_json_attr_map_create',
                                    should_error=True,
                                    **input_dict)
     assert_error(result, 'record_attr', 'Unique constraint violation')
 def test_update_valid(self):
     metadata_json_attr_map = ckanext_factories.MetadataJSONAttrMap()
     input_dict = {
         'id': metadata_json_attr_map['id'],
         'json_path': '/c/d',
         'record_attr': 'notes',
         'is_key': False,
     }
     result, obj = self.test_action('metadata_json_attr_map_update',
                                    **input_dict)
     assert_object_matches_dict(obj, input_dict)
 def test_update_invalid_json_path(self):
     metadata_json_attr_map = ckanext_factories.MetadataJSONAttrMap()
     metadata_standard = ckanext_factories.MetadataStandard(
         metadata_template_json=load_example('saeon_odp_4.2_record.json'))
     result, obj = self.test_action(
         'metadata_json_attr_map_update',
         should_error=True,
         id=metadata_json_attr_map['id'],
         metadata_standard_id=metadata_standard['id'],
         json_path='/identifier/foo')
     assert_error(
         result, '__after',
         'The supplied JSON path is not valid for the metadata template of the supplied metadata standard'
     )
 def test_delete_valid(self):
     metadata_json_attr_map = ckanext_factories.MetadataJSONAttrMap()
     self.test_action('metadata_json_attr_map_delete',
                      id=metadata_json_attr_map['id'])