Changeset View
Changeset View
Standalone View
Standalone View
swh/graph/tests/test_http_client.py
Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | def test_visit_nodes_filtered(graph_client): | ||||
expected = [ | expected = [ | ||||
"swh:1:dir:0000000000000000000000000000000000000002", | "swh:1:dir:0000000000000000000000000000000000000002", | ||||
"swh:1:dir:0000000000000000000000000000000000000008", | "swh:1:dir:0000000000000000000000000000000000000008", | ||||
"swh:1:dir:0000000000000000000000000000000000000006", | "swh:1:dir:0000000000000000000000000000000000000006", | ||||
] | ] | ||||
assert set(actual) == set(expected) | assert set(actual) == set(expected) | ||||
@pytest.mark.parametrize("max_matching_nodes", [0, 1, 2, 3, 4, 5, 10, 1 << 31]) | |||||
def test_visit_nodes_filtered_limit(graph_client, max_matching_nodes): | |||||
actual = list( | |||||
graph_client.visit_nodes( | |||||
"swh:1:rel:0000000000000000000000000000000000000010", | |||||
return_types="dir", | |||||
max_matching_nodes=max_matching_nodes, | |||||
) | |||||
) | |||||
expected = [ | |||||
"swh:1:dir:0000000000000000000000000000000000000002", | |||||
"swh:1:dir:0000000000000000000000000000000000000008", | |||||
"swh:1:dir:0000000000000000000000000000000000000006", | |||||
] | |||||
if max_matching_nodes == 0: | |||||
assert set(actual) == set(expected) | |||||
else: | |||||
assert set(actual) <= set(expected) | |||||
assert len(actual) == min(3, max_matching_nodes) | |||||
def test_visit_nodes_filtered_star(graph_client): | def test_visit_nodes_filtered_star(graph_client): | ||||
actual = list( | actual = list( | ||||
graph_client.visit_nodes( | graph_client.visit_nodes( | ||||
"swh:1:rel:0000000000000000000000000000000000000010", | "swh:1:rel:0000000000000000000000000000000000000010", | ||||
return_types="*", | return_types="*", | ||||
) | ) | ||||
) | ) | ||||
expected = [ | expected = [ | ||||
▲ Show 20 Lines • Show All 292 Lines • Show Last 20 Lines |