def test_prepare_elements_4(self): # Variable 'Production_status' set to sthg not in controlled vocabulary with open(self.default, 'r') as default_file: default = yaml.load(default_file.read(), Loader=yaml.SafeLoader) dataset = self.reference_oda_tag dataset['Production_status'] = 'Ongoing' self.assertIsNone(odajson_to_mmd.prepare_elements(dataset, default))
def test_prepare_elements_2(self): # Required element missing #2 with open(self.default, 'r') as default_file: default = yaml.load(default_file.read(), Loader=yaml.SafeLoader) dataset = self.reference_oda_tag dataset['Temporal_extent'].pop("Start_date") self.assertIsNone(odajson_to_mmd.prepare_elements(dataset, default))
def test_prepare_elements_1(self): # Required element missing #1 with open(self.default, 'r') as default_file: default = yaml.load(default_file.read(), Loader=yaml.SafeLoader) dataset = self.reference_oda_tag dataset.pop("Metadata_identifier") self.assertIsNone(odajson_to_mmd.prepare_elements(dataset, default))
def test_prepare_elements_5(self): # Variable 'Operational_status' set to default value with open(self.default, 'r') as default_file: default = yaml.load(default_file.read(), Loader=yaml.SafeLoader) dataset = self.reference_oda_tag dataset['Operational_status'] = '' out = odajson_to_mmd.prepare_elements(dataset, default) self.assertIs('operational_status' in out, False)
def test_prepare_elements_6(self): # Variable 'Keyword' includes Keyword_type that is not CF with open(self.default, 'r') as default_file: default = yaml.load(default_file.read(), Loader=yaml.SafeLoader) dataset = self.reference_oda_tag dataset['Keyword'].append({ 'Keyword_type': 'other type', 'Keywords': [11, 22] }) out = odajson_to_mmd.prepare_elements(dataset, default) self.assertEqual(out['keyword'], dataset['Keyword'])
def test_prepare_elements_3(self): # Variables lat/lon = default value with open(self.default, 'r') as default_file: default = yaml.load(default_file.read(), Loader=yaml.SafeLoader) dataset = self.reference_oda_tag dataset['Geographic_extent']['Latitude_max'] = 0. dataset['Geographic_extent']['Latitude_min'] = 0. dataset['Geographic_extent']['Longitude_max'] = 0. dataset['Geographic_extent']['Longitude_min'] = 0. out = odajson_to_mmd.prepare_elements(dataset, default) self.assertEqual(out['geographic_extent']['latitude_max'], default['geographic_extent']['latitude_max']) self.assertEqual(out['geographic_extent']['latitude_min'], default['geographic_extent']['latitude_min']) self.assertEqual(out['geographic_extent']['longitude_max'], default['geographic_extent']['longitude_max']) self.assertEqual(out['geographic_extent']['longitude_min'], default['geographic_extent']['longitude_min'])