Skip to content

Commit f2fbfc5

Browse files
committed
993 fastidious revisions by ruff
1 parent d2806c5 commit f2fbfc5

File tree

1 file changed

+39
-12
lines changed

1 file changed

+39
-12
lines changed

tests/test_collection.py

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ def test_spatial_extent_from_coordinates() -> None:
6969
for x in bbox:
7070
assert isinstance(x, float)
7171

72+
7273
def test_read_eo_items_are_heritable() -> None:
7374
cat = TestCases.case_5()
7475
item = next(cat.get_items(recursive=True))
7576

7677
assert EOExtension.has_extension(item)
7778

79+
7880
def test_save_uses_previous_catalog_type() -> None:
7981
collection = TestCases.case_8()
8082
assert collection.STAC_OBJECT_TYPE == pystac.STACObjectType.COLLECTION
@@ -87,12 +89,14 @@ def test_save_uses_previous_catalog_type() -> None:
8789
collection2 = pystac.Collection.from_file(href)
8890
assert collection2.catalog_type == CatalogType.SELF_CONTAINED
8991

92+
9093
def test_clone_uses_previous_catalog_type() -> None:
9194
catalog = TestCases.case_8()
9295
assert catalog.catalog_type == CatalogType.SELF_CONTAINED
9396
clone = catalog.clone()
9497
assert clone.catalog_type == CatalogType.SELF_CONTAINED
9598

99+
96100
def test_clone_cant_mutate_original() -> None:
97101
collection = TestCases.case_8()
98102
assert collection.keywords == ["disaster", "open"]
@@ -105,6 +109,7 @@ def test_clone_cant_mutate_original() -> None:
105109
assert collection.keywords == ["disaster", "open"]
106110
assert id(collection.summaries) != id(clone.summaries)
107111

112+
108113
def test_multiple_extents() -> None:
109114
cat1 = TestCases.case_1()
110115
country = cat1.get_child("country-1")
@@ -133,6 +138,7 @@ def test_multiple_extents() -> None:
133138
cloned_ext = ext.clone()
134139
assert cloned_ext.to_dict() == multi_ext_dict["extent"]
135140

141+
136142
def test_extra_fields() -> None:
137143
catalog = TestCases.case_2()
138144
collection = catalog.get_child("1a8c1632-fa91-4a62-b33e-3a87c2ebdf16")
@@ -152,6 +158,7 @@ def test_extra_fields() -> None:
152158
assert "test" in read_col.extra_fields
153159
assert read_col.extra_fields["test"] == "extra"
154160

161+
155162
def test_update_extents() -> None:
156163
catalog = TestCases.case_2()
157164
base_collection = catalog.get_child("1a8c1632-fa91-4a62-b33e-3a87c2ebdf16")
@@ -184,7 +191,9 @@ def test_update_extents() -> None:
184191

185192
collection.update_extent_from_items()
186193
assert [[-180, -90, 180, 90]] == collection.extent.spatial.bboxes
187-
assert len(base_extent.spatial.bboxes[0]) == len(collection.extent.spatial.bboxes[0])
194+
assert len(base_extent.spatial.bboxes[0]) == len(
195+
collection.extent.spatial.bboxes[0]
196+
)
188197
assert base_extent.temporal.intervals != collection.extent.temporal.intervals
189198

190199
collection.remove_item("test-item-1")
@@ -194,9 +203,13 @@ def test_update_extents() -> None:
194203

195204
collection.update_extent_from_items()
196205

197-
assert ( [ [ item2.common_metadata.start_datetime,
198-
base_extent.temporal.intervals[0][1],
199-
] ] == collection.extent.temporal.intervals )
206+
assert [
207+
[
208+
item2.common_metadata.start_datetime,
209+
base_extent.temporal.intervals[0][1],
210+
]
211+
] == collection.extent.temporal.intervals
212+
200213

201214
def test_supplying_href_in_init_does_not_fail() -> None:
202215
test_href = "http://example.com/collection.json"
@@ -210,6 +223,7 @@ def test_supplying_href_in_init_does_not_fail() -> None:
210223

211224
assert collection.get_self_href() == test_href
212225

226+
213227
def test_collection_with_href_caches_by_href() -> None:
214228
collection = pystac.Collection.from_file(
215229
TestCases.get_path("data-files/examples/hand-0.8.1/collection.json")
@@ -220,6 +234,7 @@ def test_collection_with_href_caches_by_href() -> None:
220234
# cached only by HREF
221235
assert len(cache.id_keys_to_objects) == 0
222236

237+
223238
@pytest.mark.block_network
224239
def test_assets() -> None:
225240
path = TestCases.get_path("data-files/collections/with-assets.json")
@@ -228,6 +243,7 @@ def test_assets() -> None:
228243
collection = pystac.Collection.from_dict(data)
229244
collection.validate()
230245

246+
231247
def test_get_assets() -> None:
232248
collection = pystac.Collection.from_file(
233249
TestCases.get_path("data-files/collections/with-assets.json")
@@ -251,6 +267,7 @@ def test_get_assets() -> None:
251267
no_assets = collection.get_assets(media_type=pystac.MediaType.HDF)
252268
assert no_assets == {}
253269

270+
254271
def test_removing_optional_attributes() -> None:
255272
path = TestCases.get_path("data-files/collections/with-assets.json")
256273
with open(path) as file:
@@ -288,6 +305,7 @@ def test_removing_optional_attributes() -> None:
288305
):
289306
assert key not in collection_as_dict
290307

308+
291309
def test_from_dict_preserves_dict() -> None:
292310
path = TestCases.get_path("data-files/collections/with-assets.json")
293311
with open(path) as f:
@@ -303,6 +321,7 @@ def test_from_dict_preserves_dict() -> None:
303321
_ = Collection.from_dict(param_dict, preserve_dict=False, migrate=False)
304322
assert param_dict != collection_dict
305323

324+
306325
def test_from_dict_set_root() -> None:
307326
path = TestCases.get_path("data-files/examples/hand-0.8.1/collection.json")
308327
with open(path) as f:
@@ -311,6 +330,7 @@ def test_from_dict_set_root() -> None:
311330
collection = Collection.from_dict(collection_dict, root=catalog)
312331
assert collection.get_root() is catalog
313332

333+
314334
def test_schema_summary() -> None:
315335
collection = pystac.Collection.from_file(
316336
TestCases.get_path(
@@ -325,6 +345,7 @@ def test_schema_summary() -> None:
325345

326346
assert isinstance(instruments_schema, dict)
327347

348+
328349
def test_from_invalid_dict_raises_exception() -> None:
329350
stac_io = pystac.StacIO.default()
330351
catalog_dict = stac_io.read_json(
@@ -333,6 +354,7 @@ def test_from_invalid_dict_raises_exception() -> None:
333354
with pytest.raises(pystac.STACTypeError):
334355
_ = pystac.Collection.from_dict(catalog_dict)
335356

357+
336358
def test_clone_preserves_assets() -> None:
337359
path = TestCases.get_path("data-files/collections/with-assets.json")
338360
original_collection = Collection.from_file(path)
@@ -348,16 +370,16 @@ def test_clone_preserves_assets() -> None:
348370
assert key in cloned_collection.assets, f"Failed to Preserve {key} asset"
349371
cloned_asset = cloned_collection.assets.get(key)
350372
if cloned_asset is not None:
351-
assert cloned_asset.owner is cloned_collection, \
352-
f"Failed to set owner for {key}"
373+
assert (
374+
cloned_asset.owner is cloned_collection
375+
), f"Failed to set owner for {key}"
376+
353377

354378
def test_to_dict_no_self_href() -> None:
355379
temporal_extent = TemporalExtent(intervals=[[TEST_DATETIME, None]])
356380
spatial_extent = SpatialExtent(bboxes=ARBITRARY_BBOX)
357381
extent = Extent(spatial=spatial_extent, temporal=temporal_extent)
358-
collection = Collection(
359-
id="an-id", description="A test Collection", extent=extent
360-
)
382+
collection = Collection(id="an-id", description="A test Collection", extent=extent)
361383
d = collection.to_dict(include_self_link=False)
362384
Collection.from_dict(d)
363385

@@ -370,6 +392,7 @@ def test_temporal_extent_init_typing() -> None:
370392

371393
_ = TemporalExtent([[start_datetime, end_datetime]])
372394

395+
373396
@pytest.mark.block_network()
374397
def test_temporal_extent_allows_single_interval() -> None:
375398
start_datetime = str_to_datetime("2022-01-01T00:00:00Z")
@@ -380,6 +403,7 @@ def test_temporal_extent_allows_single_interval() -> None:
380403

381404
assert temporal_extent.intervals == [interval]
382405

406+
383407
@pytest.mark.block_network()
384408
def test_temporal_extent_allows_single_interval_open_start() -> None:
385409
end_datetime = str_to_datetime("2022-01-31T23:59:59Z")
@@ -389,12 +413,14 @@ def test_temporal_extent_allows_single_interval_open_start() -> None:
389413

390414
assert temporal_extent.intervals == [interval]
391415

416+
392417
@pytest.mark.block_network()
393418
def test_temporal_extent_non_list_intervals_fails() -> None:
394419
with pytest.raises(TypeError):
395420
# Pass in non-list intervals
396421
_ = TemporalExtent(intervals=1) # type: ignore
397422

423+
398424
@pytest.mark.block_network()
399425
def test_spatial_allows_single_bbox() -> None:
400426
temporal_extent = TemporalExtent(intervals=[[TEST_DATETIME, None]])
@@ -413,12 +439,14 @@ def test_spatial_allows_single_bbox() -> None:
413439

414440
collection.validate()
415441

442+
416443
@pytest.mark.block_network()
417444
def test_spatial_extent_non_list_bboxes_fails() -> None:
418445
with pytest.raises(TypeError):
419446
# Pass in non-list bboxes
420447
_ = SpatialExtent(bboxes=1) # type: ignore
421448

449+
422450
def test_extent_from_items() -> None:
423451
item1 = Item(
424452
id="test-item-1",
@@ -467,6 +495,7 @@ def test_extent_from_items() -> None:
467495
assert interval[0] == datetime(2000, 1, 1, 12, 0, 0, 0, tzinfo=tz.UTC)
468496
assert interval[1] == datetime(2001, 1, 1, 12, 0, 0, 0, tzinfo=tz.UTC)
469497

498+
470499
def test_extent_to_from_dict() -> None:
471500
spatial_dict = {
472501
"bbox": [
@@ -480,9 +509,7 @@ def test_extent_to_from_dict() -> None:
480509
"extension:field": "spatial value",
481510
}
482511
temporal_dict = {
483-
"interval": [
484-
["2020-12-11T22:38:32.125000Z", "2020-12-14T18:02:31.437000Z"]
485-
],
512+
"interval": [["2020-12-11T22:38:32.125000Z", "2020-12-14T18:02:31.437000Z"]],
486513
"extension:field": "temporal value",
487514
}
488515
extent_dict = {

0 commit comments

Comments
 (0)