示例#1
0
    def test_migrate(self):
        collection_cache = CollectionCache()
        for example in self.examples:
            path = example['path']
            d = STAC_IO.read_json(path)
            if identify_stac_object_type(d) == STACObjectType.ITEM:
                merge_common_properties(d,
                                        json_href=path,
                                        collection_cache=collection_cache)

            info = identify_stac_object(d)

            migrated_d = migrate_to_latest(d, info)

            migrated_info = identify_stac_object(migrated_d)

            self.assertEqual(migrated_info.object_type, info.object_type)
            self.assertEqual(
                migrated_info.version_range.latest_valid_version(),
                STAC_VERSION)
            self.assertEqual(set(migrated_info.common_extensions),
                             set(info.common_extensions))
            self.assertEqual(set(migrated_info.custom_extensions),
                             set(info.custom_extensions))

            # Test that PySTAC can read it without errors.
            self.assertIsInstance(
                STAC_IO.stac_object_from_dict(migrated_d, href=path),
                STACObject)
示例#2
0
    def test_from_file_pre_081(self):
        d = STAC_IO.read_json(self.label_example_1_uri)

        d['stac_version'] = '0.8.0-rc1'
        d['properties']['label:property'] = d['properties']['label:properties']
        d['properties'].pop('label:properties')
        d['properties']['label:overview'] = d['properties']['label:overviews']
        d['properties'].pop('label:overviews')
        d['properties']['label:method'] = d['properties']['label:methods']
        d['properties'].pop('label:methods')
        d['properties']['label:task'] = d['properties']['label:tasks']
        d['properties'].pop('label:tasks')
        label_example_1 = STAC_IO.stac_object_from_dict(d)

        self.assertEqual(len(label_example_1.ext.label.label_tasks), 2)