Skip to content

Commit b73ac4d

Browse files
committed
Improve I/O test coverage
1 parent 3f6b58e commit b73ac4d

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

tests/test_stac_io.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
import tempfile
55

66
import pystac
7-
from pystac.stac_io import STAC_IO
7+
from pystac.stac_io import STAC_IO, StacIO
88
from tests.utils import TestCases
99

1010

1111
class StacIOTest(unittest.TestCase):
12+
def setUp(self) -> None:
13+
self.stac_io = StacIO.default()
14+
1215
def test_stac_io_issues_warnings(self) -> None:
1316
with warnings.catch_warnings(record=True) as w:
1417
# Cause all warnings to always be triggered.
@@ -87,3 +90,30 @@ def test_read_item_collection_raises_exception(self) -> None:
8790
"data-files/item-collection/sample-item-collection.json"
8891
)
8992
)
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

Comments
 (0)