Skip to content

Commit a8d6daf

Browse files
committed
Simplify ordering test
1 parent d5fb435 commit a8d6daf

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

pystac/item.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,6 @@ def to_dict(
374374
"assets": assets,
375375
}
376376

377-
if self.bbox is not None:
378-
d["bbox"] = self.bbox
379-
380-
if self.stac_extensions is not None:
381-
d["stac_extensions"] = self.stac_extensions
382-
383377
if self.collection_id:
384378
d["collection"] = self.collection_id
385379

tests/test_item.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def test_item_field_order(self) -> None:
112112
item = pystac.Item.from_file(
113113
TestCases.get_path("data-files/item/sample-item.json")
114114
)
115-
115+
item_dict = item.to_dict(include_self_link=False)
116116
expected_order = [
117117
"type",
118118
"stac_version",
@@ -125,21 +125,12 @@ def test_item_field_order(self) -> None:
125125
"assets",
126126
"collection",
127127
]
128-
129-
with tempfile.TemporaryDirectory() as tmp_dir:
130-
p = os.path.join(tmp_dir, "item.json")
131-
item.save_object(include_self_link=False, dest_href=p)
132-
133-
with open(p) as f:
134-
item_json = json.load(f)
135-
136-
# Assert the order matches the expected order
137-
actual_order = list(item_json.keys())
138-
self.assertEqual(
139-
actual_order,
140-
expected_order,
141-
f"Order was {actual_order}, expected {expected_order}",
142-
)
128+
actual_order = list(item_dict.keys())
129+
self.assertEqual(
130+
actual_order,
131+
expected_order,
132+
f"Order was {actual_order}, expected {expected_order}",
133+
)
143134

144135
def test_extra_fields(self) -> None:
145136
item = pystac.Item.from_file(

0 commit comments

Comments
 (0)