def test_metadata_date(self): metadata = OutputLayerMetadata('random_layer_id') path = TEST_XML_BASEPATH + 'gco:Date' # using QDate test_value = QDate(2015, 6, 7) metadata.set('ISO19115_TEST', test_value, path) self.assertEqual(metadata.get_xml_value('ISO19115_TEST'), '2015-06-07') # using datetime test_value = datetime(2015, 6, 7) metadata.update('ISO19115_TEST', test_value) self.assertEqual(metadata.get_xml_value('ISO19115_TEST'), '2015-06-07') # using date test_value = date(2015, 6, 7) metadata.set('ISO19115_TEST', test_value, path) self.assertEqual(metadata.get_xml_value('ISO19115_TEST'), '2015-06-07') # using str should fail test_value = 'String' with self.assertRaises(TypeError): metadata.update('ISO19115_TEST', test_value)
def test_metadata_str(self): metadata = OutputLayerMetadata('random_layer_id') path = TEST_XML_BASEPATH + 'gco:CharacterString' # using str test_value = 'Random string' metadata.set('ISO19115_TEST', test_value, path) self.assertEqual(metadata.get_xml_value('ISO19115_TEST'), 'Random string') # using int test_value = 1234 metadata.update('ISO19115_TEST', test_value) self.assertEqual(metadata.get_xml_value('ISO19115_TEST'), '1234') # using float test_value = 1234.5678 metadata.update('ISO19115_TEST', test_value) self.assertEqual(metadata.get_xml_value('ISO19115_TEST'), '1234.5678') # using invalid QUrl test_value = QUrl() with self.assertRaises(TypeError): metadata.update('ISO19115_TEST', test_value)
def test_metadata_str(self): metadata = OutputLayerMetadata('random_layer_id') path = TEST_XML_BASEPATH + 'gco:CharacterString' # using str test_value = 'Random string' metadata.set('ISO19115_TEST', test_value, path) self.assertEqual( metadata.get_xml_value('ISO19115_TEST'), 'Random string') # using int test_value = 1234 metadata.update('ISO19115_TEST', test_value) self.assertEqual(metadata.get_xml_value('ISO19115_TEST'), '1234') # using float test_value = 1234.5678 metadata.update('ISO19115_TEST', test_value) self.assertEqual(metadata.get_xml_value('ISO19115_TEST'), '1234.5678') # using invalid QUrl test_value = QUrl() with self.assertRaises(TypeError): metadata.update('ISO19115_TEST', test_value)
def test_metadata_url(self): metadata = OutputLayerMetadata('random_layer_id') path = TEST_XML_BASEPATH + 'gmd:URL' # using QUrl test_value = QUrl('http://inasafe.org') metadata.set('ISO19115_TEST', test_value, path) self.assertEqual(metadata.get_xml_value('ISO19115_TEST'), 'http://inasafe.org') # using str should work as it is casted test_value = 'http://inasafe.org' metadata.update('ISO19115_TEST', test_value) # using invalid QUrl (has a space) test_value = QUrl('http://inasafe.org ') with self.assertRaises(ValueError): metadata.set('ISO19115_TEST', test_value, path)
def test_metadata_url(self): metadata = OutputLayerMetadata('random_layer_id') path = TEST_XML_BASEPATH + 'gmd:URL' # using QUrl test_value = QUrl('http://inasafe.org') metadata.set('ISO19115_TEST', test_value, path) self.assertEqual( metadata.get_xml_value('ISO19115_TEST'), 'http://inasafe.org') # using str should work as it is casted test_value = 'http://inasafe.org' metadata.update('ISO19115_TEST', test_value) # using invalid QUrl (has a space) test_value = QUrl('http://inasafe.org ') with self.assertRaises(ValueError): metadata.set('ISO19115_TEST', test_value, path)
def test_xml_read(self): generated_metadata = OutputLayerMetadata(EXISTING_IMPACT_FILE, xml_uri=EXISTING_IMPACT_XML) # TODO (MB): add more checks self.assertEquals(generated_metadata.get_xml_value('license'), 'GPLv2')
def test_xml_read(self): generated_metadata = OutputLayerMetadata( EXISTING_IMPACT_FILE, xml_uri=EXISTING_IMPACT_XML) # TODO (MB): add more checks self.assertEquals(generated_metadata.get_xml_value('license'), 'GPLv2')