コード例 #1
0
    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)
コード例 #2
0
    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)
コード例 #3
0
    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)
コード例 #4
0
    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)
コード例 #5
0
    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)
コード例 #6
0
    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)
コード例 #7
0
    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')
コード例 #8
0
    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')