Skip to content

Commit ffc0158

Browse files
committed
More robust test for comparing rerouting actions.
This is necessary given that the order of actions seems to change randomly; presumably this depends on Gobbler's hashmap.
1 parent 90a5dcc commit ffc0158

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/test_reroute_links.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22
import os
33

44

5+
def _sort_array_of_actions(x):
6+
paths = [y["path"] for y in x]
7+
paths.sort()
8+
order = {}
9+
for i, p in enumerate(paths):
10+
order[p] = i
11+
output = [None] * len(x)
12+
for y in x:
13+
output[order[y["path"]]] = y
14+
return output
15+
16+
517
def test_reroute_links():
618
_, staging, registry, url = pyg.start_gobbler()
719

@@ -17,7 +29,6 @@ def test_reroute_links():
1729
pyg.upload_directory("test-reroute", "simple", "v3", src, staging=staging, url=url)
1830

1931
actions = pyg.reroute_links([{"project":"test-reroute", "asset":"simple", "version":"v1"}], staging=staging, url=url, dry_run=True)
20-
print(actions)
2132
assert all([x["source"] == "test-reroute/simple/v1/foo" for x in actions])
2233
all_paths = [x["path"] for x in actions]
2334
assert "test-reroute/simple/v2/foo" in all_paths
@@ -28,5 +39,5 @@ def test_reroute_links():
2839
assert os.path.islink(os.path.join(registry, "test-reroute/simple/v2/foo"))
2940

3041
actions2 = pyg.reroute_links([{"project":"test-reroute", "asset":"simple", "version":"v1"}], staging=staging, url=url)
31-
assert actions == actions2
42+
assert _sort_array_of_actions(actions) == _sort_array_of_actions(actions2)
3243
assert not os.path.islink(os.path.join(registry, "test-reroute/simple/v2/foo"))

0 commit comments

Comments
 (0)