Skip to content

Commit

Permalink
Update example filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-saeon committed Mar 15, 2019
1 parent 2d9677b commit a95dd82
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
10 changes: 5 additions & 5 deletions ckanext/metadata/tests/test_metadata_json_attr_map_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TestMetadataJSONAttrMapActions(ActionTestBase):

def test_create_valid(self):
metadata_standard = ckanext_factories.MetadataStandard(
metadata_template_json=load_example('saeon_datacite_record.json'))
metadata_template_json=load_example('datacite_4.2_saeon_record.json'))
input_dict = {
'json_path': '/identifier/identifier',
'record_attr': 'name',
Expand All @@ -28,7 +28,7 @@ def test_create_valid(self):

def test_create_valid_metadata_standard_byname(self):
metadata_standard = ckanext_factories.MetadataStandard(
metadata_template_json=load_example('saeon_datacite_record.json'))
metadata_template_json=load_example('datacite_4.2_saeon_record.json'))
input_dict = {
'json_path': '/identifier/identifier',
'record_attr': 'name',
Expand All @@ -41,7 +41,7 @@ def test_create_valid_metadata_standard_byname(self):

def test_create_valid_sysadmin_setid(self):
metadata_standard = ckanext_factories.MetadataStandard(
metadata_template_json=load_example('saeon_datacite_record.json'))
metadata_template_json=load_example('datacite_4.2_saeon_record.json'))
input_dict = {
'id': make_uuid(),
'json_path': '/identifier/identifier',
Expand Down Expand Up @@ -100,7 +100,7 @@ def test_create_invalid_bad_json_path(self):

def test_create_invalid_json_path(self):
metadata_standard = ckanext_factories.MetadataStandard(
metadata_template_json=load_example('saeon_datacite_record.json'))
metadata_template_json=load_example('datacite_4.2_saeon_record.json'))
result, obj = self.test_action('metadata_json_attr_map_create', should_error=True,
metadata_standard_id=metadata_standard['id'],
json_path='/identifier/foo')
Expand Down Expand Up @@ -168,7 +168,7 @@ def test_update_invalid_bad_json_path(self):
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_datacite_record.json'))
metadata_template_json=load_example('datacite_4.2_saeon_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'],
Expand Down
42 changes: 21 additions & 21 deletions ckanext/metadata/tests/test_metadata_record_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def setup(self):
self.owner_org = self._generate_organization()
self.metadata_collection = self._generate_metadata_collection(organization_id=self.owner_org['id'])
self.metadata_standard = ckanext_factories.MetadataStandard(
metadata_template_json=load_example('saeon_datacite_record.json'))
metadata_template_json=load_example('datacite_4.2_saeon_record.json'))

def _generate_organization(self, **kwargs):
return ckan_factories.Organization(user=self.normal_user, **kwargs)
Expand Down Expand Up @@ -153,7 +153,7 @@ def test_create_valid_map_attributes(self):
Test copying of metadata element values into package attributes via metadata JSON
attribute mappings.
"""
metadata_json = load_example('saeon_datacite_record.json')
metadata_json = load_example('datacite_4.2_saeon_record.json')
metadata_dict = json.loads(metadata_json)
identifier = metadata_dict['identifier']['identifier']
url = metadata_dict['immutableResource']['resourceURL']
Expand All @@ -173,7 +173,7 @@ def test_create_valid_no_map_empty_attributes(self):
Test that when values do not exist in the metadata JSON for the defined mappings,
the target attributes are left unchanged.
"""
metadata_json = load_example('saeon_datacite_record.json')
metadata_json = load_example('datacite_4.2_saeon_record.json')
metadata_dict = json.loads(metadata_json)
del metadata_dict['identifier']
metadata_dict['immutableResource']['resourceURL'] = ''
Expand All @@ -194,7 +194,7 @@ def test_create_valid_map_attributes_update_existing(self):
Test that we switch to an update when matching on key attributes, while non-key
attributes play no part in matching.
"""
metadata_json = load_example('saeon_datacite_record.json')
metadata_json = load_example('datacite_4.2_saeon_record.json')
metadata_dict = json.loads(metadata_json)
identifier = metadata_dict['identifier']['identifier']
url = metadata_dict['immutableResource']['resourceURL']
Expand Down Expand Up @@ -223,7 +223,7 @@ def test_create_invalid_map_attributes_mismatched_keys(self):
Test that we fail an attempt to create (update) a record when incoming key attributes
match different existing records.
"""
metadata_json = load_example('saeon_datacite_record.json')
metadata_json = load_example('datacite_4.2_saeon_record.json')
metadata_dict = json.loads(metadata_json)
identifier1 = metadata_dict['identifier']['identifier']
url1 = metadata_dict['immutableResource']['resourceURL']
Expand Down Expand Up @@ -256,7 +256,7 @@ def test_create_invalid_map_attributes_partial_keys_1(self):
Test that we fail an attempt to create (update) a record when some of the incoming key
attributes do not match the existing record.
"""
metadata_json = load_example('saeon_datacite_record.json')
metadata_json = load_example('datacite_4.2_saeon_record.json')
metadata_dict = json.loads(metadata_json)
identifier = metadata_dict['identifier']['identifier']
url = metadata_dict['immutableResource']['resourceURL']
Expand All @@ -281,7 +281,7 @@ def test_create_invalid_map_attributes_partial_keys_2(self):
Test that we fail an attempt to create (update) a record when some of the incoming key
attributes required to match the existing record are not provided.
"""
metadata_json = load_example('saeon_datacite_record.json')
metadata_json = load_example('datacite_4.2_saeon_record.json')
metadata_dict = json.loads(metadata_json)
identifier = metadata_dict['identifier']['identifier']
url = metadata_dict['immutableResource']['resourceURL']
Expand Down Expand Up @@ -532,7 +532,7 @@ def test_update_valid_map_attributes(self):
metadata_record = self._generate_metadata_record()
input_dict = self._make_input_dict_from_output_dict(metadata_record)

metadata_json = load_example('saeon_datacite_record.json')
metadata_json = load_example('datacite_4.2_saeon_record.json')
metadata_dict = json.loads(metadata_json)
identifier = metadata_dict['identifier']['identifier']
url = metadata_dict['immutableResource']['resourceURL']
Expand All @@ -554,7 +554,7 @@ def test_update_valid_no_map_empty_attributes(self):
metadata_record = self._generate_metadata_record()
input_dict = self._make_input_dict_from_output_dict(metadata_record)

metadata_json = load_example('saeon_datacite_record.json')
metadata_json = load_example('datacite_4.2_saeon_record.json')
metadata_dict = json.loads(metadata_json)
del metadata_dict['identifier']
metadata_dict['immutableResource']['resourceURL'] = ''
Expand All @@ -577,7 +577,7 @@ def test_update_valid_modify_key_attributes(self):
self._define_attribute_map('/identifier/identifier', 'name', is_key=True)
self._define_attribute_map('/immutableResource/resourceURL', 'url', is_key=True)

metadata_json = load_example('saeon_datacite_record.json')
metadata_json = load_example('datacite_4.2_saeon_record.json')
metadata_dict = json.loads(metadata_json)
identifier1 = metadata_dict['identifier']['identifier']
url1 = metadata_dict['immutableResource']['resourceURL']
Expand Down Expand Up @@ -605,7 +605,7 @@ def test_update_invalid_map_attributes_mismatched_keys(self):
metadata_record = self._generate_metadata_record()
input_dict = self._make_input_dict_from_output_dict(metadata_record)

metadata_json = load_example('saeon_datacite_record.json')
metadata_json = load_example('datacite_4.2_saeon_record.json')
metadata_dict = json.loads(metadata_json)
identifier1 = metadata_dict['identifier']['identifier']
url1 = metadata_dict['immutableResource']['resourceURL']
Expand Down Expand Up @@ -640,7 +640,7 @@ def test_update_invalid_map_attributes_partial_keys_1(self):
metadata_record = self._generate_metadata_record()
input_dict = self._make_input_dict_from_output_dict(metadata_record)

metadata_json = load_example('saeon_datacite_record.json')
metadata_json = load_example('datacite_4.2_saeon_record.json')
metadata_dict = json.loads(metadata_json)
identifier = metadata_dict['identifier']['identifier']
url = metadata_dict['immutableResource']['resourceURL']
Expand All @@ -667,7 +667,7 @@ def test_update_invalid_map_attributes_partial_keys_2(self):
metadata_record = self._generate_metadata_record()
input_dict = self._make_input_dict_from_output_dict(metadata_record)

metadata_json = load_example('saeon_datacite_record.json')
metadata_json = load_example('datacite_4.2_saeon_record.json')
metadata_dict = json.loads(metadata_json)
identifier = metadata_dict['identifier']['identifier']
url = metadata_dict['immutableResource']['resourceURL']
Expand All @@ -694,7 +694,7 @@ def test_update_invalid_modify_key_attributes_match_another_record(self):
self._define_attribute_map('/identifier/identifier', 'name', is_key=True)
self._define_attribute_map('/immutableResource/resourceURL', 'url', is_key=True)

metadata_json = load_example('saeon_datacite_record.json')
metadata_json = load_example('datacite_4.2_saeon_record.json')
metadata_dict = json.loads(metadata_json)
identifier1 = metadata_dict['identifier']['identifier']
url1 = metadata_dict['immutableResource']['resourceURL']
Expand Down Expand Up @@ -818,10 +818,10 @@ def test_invalidate(self):

def test_validate_datacite(self):
metadata_record = self._generate_metadata_record(
metadata_json=load_example('saeon_datacite_record.json'))
metadata_json=load_example('datacite_4.2_saeon_record.json'))
metadata_schema = ckanext_factories.MetadataSchema(
metadata_standard_id=metadata_record['metadata_standard_id'],
schema_json=load_example('saeon_datacite_schema.json'))
schema_json=load_example('datacite_4.2_saeon_schema.json'))
ckan_factories.Vocabulary(name='language-tags', tags=[{'name': 'en-us'}])

assert_metadata_record_has_validation_schemas(metadata_record['id'], metadata_schema['name'])
Expand Down Expand Up @@ -912,7 +912,7 @@ def test_workflow_annotation_invalid_key_name(self):

def test_workflow_transition_submitted(self):
metadata_record = self._generate_metadata_record(
metadata_json=load_example('saeon_datacite_record.json'))
metadata_json=load_example('datacite_4.2_saeon_record.json'))
workflow_state_submitted = ckanext_factories.WorkflowState(
workflow_rules_json=load_example('workflow_state_submitted_rules.json'))
ckanext_factories.WorkflowTransition(
Expand Down Expand Up @@ -987,7 +987,7 @@ def test_workflow_transition_submitted(self):

def test_workflow_transition_captured(self):
metadata_record = self._generate_metadata_record(
metadata_json=load_example('saeon_datacite_record.json'))
metadata_json=load_example('datacite_4.2_saeon_record.json'))
workflow_state_captured = ckanext_factories.WorkflowState(
workflow_rules_json=load_example('workflow_state_captured_rules.json'))
ckanext_factories.WorkflowTransition(
Expand Down Expand Up @@ -1058,7 +1058,7 @@ def test_workflow_transition_captured(self):
# assert_package_has_extra(metadata_record['id'], 'workflow_state_id', workflow_state_captured['id'])

def test_workflow_transition_published(self):
metadata_json = json.loads(load_example('saeon_datacite_record.json'))
metadata_json = json.loads(load_example('datacite_4.2_saeon_record.json'))
metadata_json['identifier']['identifier'] = 'foo'
metadata_json['immutableResource']['resourceURL'] = 'http://inaccessible.url'
metadata_json['linkedResources'][0]['resourceURL'] = 'http://inaccessible.url'
Expand All @@ -1067,7 +1067,7 @@ def test_workflow_transition_published(self):

ckanext_factories.MetadataSchema(
metadata_standard_id=metadata_record['metadata_standard_id'],
schema_json=load_example('saeon_datacite_schema.json'))
schema_json=load_example('datacite_4.2_saeon_schema.json'))
call_action('metadata_record_validate', id=metadata_record['id'], context={'user': self.normal_user['name']})

workflow_state_published = ckanext_factories.WorkflowState(
Expand Down Expand Up @@ -1105,7 +1105,7 @@ def test_workflow_transition_published(self):
})
assert_package_has_extra(metadata_record['id'], 'workflow_state_id', '')

metadata_record['metadata_json'] = load_example('saeon_datacite_record.json')
metadata_record['metadata_json'] = load_example('datacite_4.2_saeon_record.json')
call_action('metadata_record_update', context={'user': self.normal_user['name']}, **metadata_record)
call_action('metadata_record_validate', id=metadata_record['id'], context={'user': self.normal_user['name']})

Expand Down
4 changes: 2 additions & 2 deletions ckanext/metadata/tests/test_metadata_schema_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_create_valid_datacite(self):
'metadata_standard_id': metadata_standard['id'],
'organization_id': '',
'infrastructure_id': '',
'schema_json': load_example('saeon_datacite_schema.json'),
'schema_json': load_example('datacite_4.2_saeon_schema.json'),
}
result, obj = self.test_action('metadata_schema_create', **input_dict)
assert_object_matches_dict(obj, input_dict)
Expand Down Expand Up @@ -432,7 +432,7 @@ def test_update_valid_datacite(self):
'metadata_standard_id': metadata_schema['metadata_standard_id'],
'organization_id': '',
'infrastructure_id': '',
'schema_json': load_example('saeon_datacite_schema.json'),
'schema_json': load_example('datacite_4.2_saeon_schema.json'),
}
result, obj = self.test_action('metadata_schema_update', **input_dict)
assert_object_matches_dict(obj, input_dict)
Expand Down

0 comments on commit a95dd82

Please sign in to comment.