|
4 | 4 | import tempfile
|
5 | 5 |
|
6 | 6 | import pystac
|
7 |
| -from pystac.stac_io import STAC_IO |
| 7 | +from pystac.stac_io import STAC_IO, StacIO |
8 | 8 | from tests.utils import TestCases
|
9 | 9 |
|
10 | 10 |
|
11 | 11 | class StacIOTest(unittest.TestCase):
|
| 12 | + def setUp(self) -> None: |
| 13 | + self.stac_io = StacIO.default() |
| 14 | + |
12 | 15 | def test_stac_io_issues_warnings(self) -> None:
|
13 | 16 | with warnings.catch_warnings(record=True) as w:
|
14 | 17 | # Cause all warnings to always be triggered.
|
@@ -87,3 +90,30 @@ def test_read_item_collection_raises_exception(self) -> None:
|
87 | 90 | "data-files/item-collection/sample-item-collection.json"
|
88 | 91 | )
|
89 | 92 | )
|
| 93 | + |
| 94 | + def test_read_item_dict(self) -> None: |
| 95 | + item_dict = self.stac_io.read_json( |
| 96 | + TestCases.get_path("data-files/item/sample-item.json") |
| 97 | + ) |
| 98 | + item = pystac.read_dict(item_dict) |
| 99 | + self.assertIsInstance(item, pystac.Item) |
| 100 | + |
| 101 | + def test_read_collection_dict(self) -> None: |
| 102 | + collection_dict = self.stac_io.read_json( |
| 103 | + TestCases.get_path("data-files/collections/multi-extent.json") |
| 104 | + ) |
| 105 | + collection = pystac.read_dict(collection_dict) |
| 106 | + self.assertIsInstance(collection, pystac.Collection) |
| 107 | + |
| 108 | + def test_read_catalog_dict(self) -> None: |
| 109 | + catalog_dict = self.stac_io.read_json( |
| 110 | + TestCases.get_path("data-files/catalogs/test-case-1/catalog.json") |
| 111 | + ) |
| 112 | + catalog = pystac.read_dict(catalog_dict) |
| 113 | + self.assertIsInstance(catalog, pystac.Catalog) |
| 114 | + |
| 115 | + def test_read_from_stac_object(self) -> None: |
| 116 | + catalog = pystac.STACObject.from_file( |
| 117 | + TestCases.get_path("data-files/catalogs/test-case-1/catalog.json") |
| 118 | + ) |
| 119 | + self.assertIsInstance(catalog, pystac.Catalog) |
0 commit comments