@@ -66,11 +66,18 @@ def test_directory_loader_populator_runner(prune_option: bool):
66
66
assert request_mock .calls [1 ].request .path_url == "/stac/collections"
67
67
assert request_mock .calls [1 ].request .body == file_contents ["collection.json" ]
68
68
69
- assert request_mock .calls [2 ].request .path_url == f"/stac/collections/{ base_col } /items"
70
- assert request_mock .calls [2 ].request .body == file_contents ["item-0.json" ]
69
+ # NOTE:
70
+ # Because directory crawler users 'os.walk', loading order is OS-dependant.
71
+ # Since the order does not actually matter, consider item indices interchangeably.
72
+ req0_json = json .loads (request_mock .calls [2 ].request .body .decode ())
73
+ req0_item = req0_json ["id" ]
74
+ item0_idx , item1_idx = (2 , 3 ) if "sample-0" in req0_item else (3 , 2 )
71
75
72
- assert request_mock .calls [3 ].request .path_url == f"/stac/collections/{ base_col } /items"
73
- assert request_mock .calls [3 ].request .body == file_contents ["item-1.json" ]
76
+ assert request_mock .calls [item0_idx ].request .path_url == f"/stac/collections/{ base_col } /items"
77
+ assert request_mock .calls [item0_idx ].request .body == file_contents ["item-0.json" ]
78
+
79
+ assert request_mock .calls [item1_idx ].request .path_url == f"/stac/collections/{ base_col } /items"
80
+ assert request_mock .calls [item1_idx ].request .body == file_contents ["item-1.json" ]
74
81
75
82
if not prune_option :
76
83
assert request_mock .calls [4 ].request .url == stac_host
@@ -79,8 +86,15 @@ def test_directory_loader_populator_runner(prune_option: bool):
79
86
assert request_mock .calls [5 ].request .path_url == "/stac/collections"
80
87
assert request_mock .calls [5 ].request .body == file_contents ["nested/collection.json" ]
81
88
82
- assert request_mock .calls [6 ].request .path_url == f"/stac/collections/{ nested_col } /items"
83
- assert request_mock .calls [6 ].request .body == file_contents ["nested/item-0.json" ]
89
+ # NOTE:
90
+ # Because directory crawler users 'os.walk', loading order is OS-dependant.
91
+ # Since the order does not actually matter, consider item indices interchangeably.
92
+ req0_json = json .loads (request_mock .calls [6 ].request .body .decode ())
93
+ req0_item = req0_json ["id" ]
94
+ item0_idx , item1_idx = (6 , 7 ) if "sample-0" in req0_item else (7 , 6 )
95
+
96
+ assert request_mock .calls [item0_idx ].request .path_url == f"/stac/collections/{ nested_col } /items"
97
+ assert request_mock .calls [item0_idx ].request .body == file_contents ["nested/item-0.json" ]
84
98
85
- assert request_mock .calls [7 ].request .path_url == f"/stac/collections/{ nested_col } /items"
86
- assert request_mock .calls [7 ].request .body == file_contents ["nested/item-1.json" ]
99
+ assert request_mock .calls [item1_idx ].request .path_url == f"/stac/collections/{ nested_col } /items"
100
+ assert request_mock .calls [item1_idx ].request .body == file_contents ["nested/item-1.json" ]
0 commit comments