@@ -50,6 +50,7 @@ def test_apply(self) -> None:
50
50
class FileTest (unittest .TestCase ):
51
51
FILE_ITEM_EXAMPLE_URI = TestCases .get_path ("data-files/file/item.json" )
52
52
FILE_COLLECTION_EXAMPLE_URI = TestCases .get_path ("data-files/file/collection.json" )
53
+ PLAIN_ITEM = TestCases .get_path ("data-files/item/sample-item.json" )
53
54
54
55
def setUp (self ) -> None :
55
56
self .maxDiff = None
@@ -188,3 +189,25 @@ def test_migrates_old_checksum(self) -> None:
188
189
FileExtension .ext (item .assets ["noises" ]).checksum ,
189
190
"90e40210a30d1711e81a4b11ef67b28744321659" ,
190
191
)
192
+
193
+ def test_extension_type_error (self ) -> None :
194
+ item = pystac .Item .from_file (self .FILE_ITEM_EXAMPLE_URI )
195
+
196
+ with self .assertRaises (pystac .ExtensionTypeError ):
197
+ _ = FileExtension .ext (item ) # type: ignore
198
+
199
+ def test_extension_not_implemented (self ) -> None :
200
+ # Should raise exception if Item does not include extension URI
201
+ item = pystac .Item .from_file (self .PLAIN_ITEM )
202
+ asset = item .assets ["thumbnail" ]
203
+
204
+ with self .assertRaises (pystac .ExtensionNotImplemented ):
205
+ _ = FileExtension .ext (asset )
206
+
207
+ # Should succeed if Asset has no owner
208
+ stac_io = pystac .StacIO .default ()
209
+ item_dict = stac_io .read_json (self .FILE_ITEM_EXAMPLE_URI )
210
+ asset_dict = item_dict ["assets" ]["measurement" ]
211
+ ownerless_asset = pystac .Asset .from_dict (asset_dict )
212
+
213
+ _ = FileExtension .ext (ownerless_asset )
0 commit comments