def test_multiple_extents(self): cat1 = TestCases.test_case_1() col1 = cat1.get_child('country-1').get_child('area-1-1') col1.validate() self.assertIsInstance(col1, Collection) validate_dict(col1.to_dict(), STACObjectType.COLLECTION) multi_ext_uri = TestCases.get_path( 'data-files/collections/multi-extent.json') with open(multi_ext_uri) as f: multi_ext_dict = json.load(f) validate_dict(multi_ext_dict, STACObjectType.COLLECTION) self.assertIsInstance(Collection.from_dict(multi_ext_dict), Collection) multi_ext_col = Collection.from_file(multi_ext_uri) multi_ext_col.validate() ext = multi_ext_col.extent extent_dict = multi_ext_dict['extent'] self.assertIsInstance(ext, Extent) self.assertIsInstance(ext.spatial.bboxes[0], list) self.assertEqual(len(ext.spatial.bboxes), 2) self.assertDictEqual(ext.to_dict(), extent_dict) cloned_ext = ext.clone() self.assertDictEqual(cloned_ext.to_dict(), multi_ext_dict['extent'])
def test_null_geometry(self) -> None: m = TestCases.get_path( "data-files/examples/1.0.0-beta.2/item-spec/examples/null-geom-item.json" ) with open(m) as f: item_dict = json.load(f) validate_dict(item_dict, pystac.STACObjectType.ITEM) item = Item.from_dict(item_dict) self.assertIsInstance(item, Item) item.validate() item_dict = item.to_dict() self.assertIsNone(item_dict["geometry"]) self.assertNotIn("bbox", item_dict)
def test_null_geometry(self): m = TestCases.get_path( 'data-files/examples/1.0.0-beta.2/item-spec/examples/null-geom-item.json' ) with open(m) as f: item_dict = json.load(f) validate_dict(item_dict, STACObjectType.ITEM) item = Item.from_dict(item_dict) self.assertIsInstance(item, Item) item.validate() item_dict = item.to_dict() self.assertIsNone(item_dict['geometry']) with self.assertRaises(KeyError): item_dict['bbox']
def validate_file(self, path, object_type): d = STAC_IO.read_json(path) return validate_dict(d, object_type)
def validate_file(self, path: str, object_type: str) -> List[Any]: d = pystac.StacIO.default().read_json(path) return validate_dict(d, pystac.STACObjectType(object_type))