Changeset View
Changeset View
Standalone View
Standalone View
swh/graph/tests/test_api_client.py
Show First 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | expected = [ | ||||
), | ), | ||||
] | ] | ||||
assert set(actual) == set(expected) | assert set(actual) == set(expected) | ||||
def test_visit_edges_limited(graph_client): | def test_visit_edges_limited(graph_client): | ||||
actual = list( | actual = list( | ||||
graph_client.visit_edges( | graph_client.visit_edges( | ||||
"swh:1:rel:0000000000000000000000000000000000000010", max_edges=4 | "swh:1:rel:0000000000000000000000000000000000000010", | ||||
max_edges=4, | |||||
edges="rel:rev,rev:rev,rev:dir", | |||||
) | ) | ||||
) | ) | ||||
expected = [ | expected = [ | ||||
( | ( | ||||
"swh:1:rel:0000000000000000000000000000000000000010", | "swh:1:rel:0000000000000000000000000000000000000010", | ||||
"swh:1:rev:0000000000000000000000000000000000000009", | "swh:1:rev:0000000000000000000000000000000000000009", | ||||
), | ), | ||||
( | ( | ||||
"swh:1:rev:0000000000000000000000000000000000000009", | "swh:1:rev:0000000000000000000000000000000000000009", | ||||
"swh:1:dir:0000000000000000000000000000000000000008", | "swh:1:rev:0000000000000000000000000000000000000003", | ||||
), | ), | ||||
( | ( | ||||
"swh:1:rev:0000000000000000000000000000000000000009", | "swh:1:rev:0000000000000000000000000000000000000009", | ||||
"swh:1:dir:0000000000000000000000000000000000000008", | |||||
), | |||||
( | |||||
"swh:1:rev:0000000000000000000000000000000000000003", | "swh:1:rev:0000000000000000000000000000000000000003", | ||||
"swh:1:dir:0000000000000000000000000000000000000002", | |||||
), | ), | ||||
] | ] | ||||
assert set(actual) == set(expected) | # As there are four valid answers (up to reordering), we cannot check for | ||||
# equality. Instead, we check the client returned all edges but one. | |||||
assert set(actual).issubset(set(expected)) | |||||
assert len(actual) == 3 | |||||
seirl: Maybe a comment would help here, just to explain that there are two semantically valid answers… | |||||
def test_visit_edges_diamond_pattern(graph_client): | def test_visit_edges_diamond_pattern(graph_client): | ||||
actual = list( | actual = list( | ||||
graph_client.visit_edges( | graph_client.visit_edges( | ||||
"swh:1:rev:0000000000000000000000000000000000000009", edges="*", | "swh:1:rev:0000000000000000000000000000000000000009", edges="*", | ||||
) | ) | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 192 Lines • Show Last 20 Lines |
Maybe a comment would help here, just to explain that there are two semantically valid answers and that this checks we're getting one of the two. It took me a while to get what you were doing.