def test_global_attributes_present(self): """Test that desired global attributes are added to the prefix cube so that Iris2 keeps these attributes global in any resultant netCDF file saved using these cubes""" cube_list = ([self.cube]) metadata_cubelist = append_metadata_cube(cube_list, self.global_keys_ref) keys_in_prefix_cube = metadata_cubelist[1].attributes # Get the global keys from both prefix and data cubes prefix_global_keys = [ k for k in keys_in_prefix_cube.keys() if k in self.global_keys_ref ] data_cube_global_keys = [ k for k in self.cube.attributes.keys() if k in self.global_keys_ref ] # Check the keys are the same for prefix and data cube self.assertListEqual(sorted(prefix_global_keys), sorted(data_cube_global_keys)) # Check the key values are the same for prefix and data cube. for key in prefix_global_keys: self.assertEqual(metadata_cubelist[-1].attributes[key], self.cube.attributes[key])
def test_bald_attribute_added(self): """Test that the bald__isPrefixedBy attribute is added to each cube and points to prefix_list""" cube_list = ([self.cube, self.cube]) metadata_cubelist = append_metadata_cube(cube_list, self.global_keys_ref) for cube in metadata_cubelist: self.assertTrue( cube.attributes['bald__isPrefixedBy'] is 'prefix_list')
def test_prefix_cube_attributes(self): """Test that metadata prefix cube contains the correct attributes""" prefix_dict = { 'spp__': 'http://reference.metoffice.gov.uk/statistical-process' '/properties/', 'bald__isPrefixedBy': 'prefix_list', 'bald__': 'http://binary-array-ld.net/latest/', 'spv__': 'http://reference.metoffice.gov.uk/statistical-process' '/values/', 'rdf__': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'spd__': 'http://reference.metoffice.gov.uk/statistical-process' '/def/'} metadata_cubelist = append_metadata_cube([], self.global_keys_ref) self.assertDictEqual(metadata_cubelist[0].attributes, prefix_dict)