def test_add_item_collections(self) -> None: item_1 = pystac.Item.from_file(self.SIMPLE_ITEM) item_2 = pystac.Item.from_file(self.EXTENDED_ITEM) item_3 = pystac.Item.from_file(self.CORE_ITEM) item_collection_1 = pystac.ItemCollection(items=[item_1, item_2]) item_collection_2 = pystac.ItemCollection(items=[item_2, item_3]) combined = item_collection_1 + item_collection_2 self.assertEqual(len(combined), 3)
def test_item_collection_iter(self) -> None: expected_ids = [item.id for item in self.items] item_collection = pystac.ItemCollection(items=self.items) actual_ids = [item.id for item in item_collection] self.assertListEqual(expected_ids, actual_ids)
def test_item_collection_to_dict(self) -> None: item_collection = pystac.ItemCollection( items=self.items, extra_fields={"custom_field": "My value"}) d = item_collection.to_dict() self.assertEqual(len(d["features"]), len(self.items)) self.assertEqual(d.get("custom_field"), "My value")
def test_item_collection_extra_fields(self) -> None: item_collection = pystac.ItemCollection( items=self.items, extra_fields={"custom_field": "My value"}) self.assertEqual(item_collection.extra_fields.get("custom_field"), "My value")
def test_item_collection_contains(self) -> None: item = pystac.Item.from_file(self.SIMPLE_ITEM) item_collection = pystac.ItemCollection(items=[item]) self.assertIn(item, item_collection)
def test_item_collection_get_item_by_index(self) -> None: expected_id = self.items[0].id item_collection = pystac.ItemCollection(items=self.items) self.assertEqual(item_collection[0].id, expected_id)
def test_item_collection_length(self) -> None: item_collection = pystac.ItemCollection(items=self.items) self.assertEqual(len(item_collection), len(self.items))
def test_from_list_of_dicts(self) -> None: item_dict = self.stac_io.read_json(self.SIMPLE_ITEM) item_collection = pystac.ItemCollection(items=[item_dict], clone_items=True) self.assertEqual(item_collection[0].id, item_dict.get("id"))