@@ -32,6 +32,15 @@ def pc_item(example_uri) -> pystac.Item:
3232 return pystac .Item .from_file (example_uri )
3333
3434
35+ @pytest .fixture
36+ def pc_no_stats_item () -> pystac .Item :
37+ return pystac .Item .from_file (TestCases .get_path (
38+ "data-files/pointcloud/example-laz-no-statistics.json" ))
39+
40+ @pytest .fixture
41+ def plain_item () -> pystac .Item :
42+ return pystac .Item .from_file (TestCases .get_path ("data-files/item/sample-item.json" ))
43+
3544def test_to_from_dict (example_uri : str ) -> None :
3645 with open (example_uri ) as f :
3746 d = json .load (f )
@@ -78,9 +87,7 @@ def test_count(pc_item: pystac.Item) -> None:
7887
7988
8089@pytest .mark .vcr ()
81- def test_type (self ) -> None :
82- pc_item = pystac .Item .from_file (self .example_uri )
83-
90+ def test_type (pc_item : pystac .Item ) -> None :
8491 # Get
8592 assert "pc:type" in pc_item .properties
8693 pc_type = PointcloudExtension .ext (pc_item ).type
@@ -94,9 +101,7 @@ def test_type(self) -> None:
94101 pc_item .validate ()
95102
96103@pytest .mark .vcr ()
97- def test_encoding (self ) -> None :
98- pc_item = pystac .Item .from_file (self .example_uri )
99-
104+ def test_encoding (pc_item : pystac .Item ) -> None :
100105 # Get
101106 assert "pc:encoding" in pc_item .properties
102107 pc_encoding = PointcloudExtension .ext (pc_item ).encoding
@@ -110,9 +115,7 @@ def test_encoding(self) -> None:
110115 pc_item .validate ()
111116
112117@pytest .mark .vcr ()
113- def test_schemas (self ) -> None :
114- pc_item = pystac .Item .from_file (self .example_uri )
115-
118+ def test_schemas (pc_item : pystac .Item ) -> None :
116119 # Get
117120 assert "pc:schemas" in pc_item .properties
118121 pc_schemas = [s .to_dict () for s in PointcloudExtension .ext (pc_item ).schemas ]
@@ -126,9 +129,7 @@ def test_schemas(self) -> None:
126129 pc_item .validate ()
127130
128131@pytest .mark .vcr ()
129- def test_statistics (self ) -> None :
130- pc_item = pystac .Item .from_file (self .example_uri )
131-
132+ def test_statistics (pc_item : pystac .Item ) -> None :
132133 # Get
133134 assert "pc:statistics" in pc_item .properties
134135 statistics = PointcloudExtension .ext (pc_item ).statistics
@@ -157,8 +158,7 @@ def test_statistics(self) -> None:
157158 pc_item .validate ()
158159
159160@pytest .mark .vcr ()
160- def test_density (self ) -> None :
161- pc_item = pystac .Item .from_file (self .example_uri )
161+ def test_density (pc_item : pystac .Item ) -> None :
162162 # Get
163163 assert "pc:density" in pc_item .properties
164164 pc_density = PointcloudExtension .ext (pc_item ).density
@@ -170,7 +170,7 @@ def test_density(self) -> None:
170170 # Validate
171171 pc_item .validate ()
172172
173- def test_pointcloud_schema (self ) -> None :
173+ def test_pointcloud_schema () -> None :
174174 props : dict [str , Any ] = {
175175 "name" : "test" ,
176176 "size" : 8 ,
@@ -198,11 +198,10 @@ def test_pointcloud_schema(self) -> None:
198198
199199 empty_schema = Schema ({})
200200 for required_prop in {"size" , "name" , "type" }:
201- with self .subTest (attr = required_prop ):
202- with pytest .raises (RequiredPropertyMissing ):
203- getattr (empty_schema , required_prop )
201+ with pytest .raises (RequiredPropertyMissing ):
202+ getattr (empty_schema , required_prop )
204203
205- def test_pointcloud_statistics (self ) -> None :
204+ def test_pointcloud_statistics () -> None :
206205 props : dict [str , Any ] = {
207206 "average" : 1 ,
208207 "count" : 1 ,
@@ -256,11 +255,10 @@ def test_pointcloud_statistics(self) -> None:
256255 with pytest .raises (RequiredPropertyMissing ):
257256 empty_stat .name
258257
259- def test_statistics_accessor_when_no_stats (self ) -> None :
260- pc_item = pystac .Item .from_file (self .example_uri_no_statistics )
261- assert PointcloudExtension .ext (pc_item ).statistics == None
258+ def test_statistics_accessor_when_no_stats (pc_no_stats_item : pystac .Item ) -> None :
259+ assert PointcloudExtension .ext (pc_no_stats_item ).statistics == None
262260
263- def test_asset_extension (self ) -> None :
261+ def test_asset_extension (pc_no_stats_item : pystac . Item ) -> None :
264262 asset = Asset (
265263 "https://github.com/PDAL/PDAL/blob"
266264 "/a6c986f68458e92414a66c664408bee4737bbb08/test/data/laz"
@@ -271,16 +269,14 @@ def test_asset_extension(self) -> None:
271269 ["data" ],
272270 {"foo" : "bar" },
273271 )
274- pc_item = pystac .Item .from_file (self .example_uri_no_statistics )
275- pc_item .add_asset ("data" , asset )
272+ pc_no_stats_item .add_asset ("data" , asset )
276273 ext = AssetPointcloudExtension (asset )
277274 assert ext .asset_href == asset .href
278275 assert ext .properties == asset .extra_fields
279- assert ext .additional_read_properties == [pc_item .properties ]
276+ assert ext .additional_read_properties == [pc_no_stats_item .properties ]
280277
281- def test_ext (self ) -> None :
282- pc_item = pystac .Item .from_file (self .example_uri_no_statistics )
283- PointcloudExtension .ext (pc_item )
278+ def test_ext (pc_no_stats_item : pystac .Item ) -> None :
279+ PointcloudExtension .ext (pc_no_stats_item )
284280 asset = Asset (
285281 "https://github.com/PDAL/PDAL/blob"
286282 "/a6c986f68458e92414a66c664408bee4737bbb08/test/data/laz"
@@ -301,16 +297,13 @@ class RandomObject:
301297 # calling it wrong on purpose so -----------------v
302298 PointcloudExtension .ext (RandomObject ()) # type: ignore
303299
304- def test_extension_not_implemented (self ) -> None :
300+ def test_extension_not_implemented (plain_item : pystac . Item ) -> None :
305301 # Should raise exception if Item does not include extension URI
306- plain_item_uri = TestCases .get_path ("data-files/item/sample-item.json" )
307- item = pystac .Item .from_file (plain_item_uri )
308-
309302 with pytest .raises (pystac .ExtensionNotImplemented ):
310- _ = PointcloudExtension .ext (item )
303+ _ = PointcloudExtension .ext (plain_item )
311304
312305 # Should raise exception if owning Item does not include extension URI
313- asset = item .assets ["thumbnail" ]
306+ asset = plain_item .assets ["thumbnail" ]
314307
315308 with pytest .raises (pystac .ExtensionNotImplemented ):
316309 _ = PointcloudExtension .ext (asset )
@@ -319,24 +312,20 @@ def test_extension_not_implemented(self) -> None:
319312 ownerless_asset = pystac .Asset .from_dict (asset .to_dict ())
320313 _ = PointcloudExtension .ext (ownerless_asset )
321314
322- def test_item_ext_add_to (self ) -> None :
323- plain_item_uri = TestCases .get_path ("data-files/item/sample-item.json" )
324- item = pystac .Item .from_file (plain_item_uri )
325- assert PointcloudExtension .get_schema_uri () not in item .stac_extensions
315+ def test_item_ext_add_to (plain_item : pystac .Item ) -> None :
316+ assert PointcloudExtension .get_schema_uri () not in plain_item .stac_extensions
326317
327- _ = PointcloudExtension .ext (item , add_if_missing = True )
318+ _ = PointcloudExtension .ext (plain_item , add_if_missing = True )
328319
329- assert PointcloudExtension .get_schema_uri () in item .stac_extensions
320+ assert PointcloudExtension .get_schema_uri () in plain_item .stac_extensions
330321
331- def test_asset_ext_add_to (self ) -> None :
332- plain_item_uri = TestCases .get_path ("data-files/item/sample-item.json" )
333- item = pystac .Item .from_file (plain_item_uri )
334- assert PointcloudExtension .get_schema_uri () not in item .stac_extensions
335- asset = item .assets ["thumbnail" ]
322+ def test_asset_ext_add_to (plain_item : pystac .Item ) -> None :
323+ assert PointcloudExtension .get_schema_uri () not in plain_item .stac_extensions
324+ asset = plain_item .assets ["thumbnail" ]
336325
337326 _ = PointcloudExtension .ext (asset , add_if_missing = True )
338327
339- assert PointcloudExtension .get_schema_uri () in item .stac_extensions
328+ assert PointcloudExtension .get_schema_uri () in plain_item .stac_extensions
340329
341330
342331class PointcloudSummariesTest (unittest .TestCase ):
0 commit comments