Changeset View
Changeset View
Standalone View
Standalone View
swh/graph/tests/test_graph.py
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | def test_visit_nodes(graph): | ||||
expected = [ | expected = [ | ||||
"swh:1:rel:0000000000000000000000000000000000000010", | "swh:1:rel:0000000000000000000000000000000000000010", | ||||
"swh:1:rev:0000000000000000000000000000000000000009", | "swh:1:rev:0000000000000000000000000000000000000009", | ||||
"swh:1:rev:0000000000000000000000000000000000000003", | "swh:1:rev:0000000000000000000000000000000000000003", | ||||
] | ] | ||||
assert set(actual) == set(expected) | assert set(actual) == set(expected) | ||||
def test_visit_edges(graph): | |||||
actual = list( | |||||
graph["swh:1:rel:0000000000000000000000000000000000000010"].visit_edges( | |||||
edges="rel:rev,rev:rev,rev:dir" | |||||
) | |||||
) | |||||
actual = [(src.pid, dst.pid) for src, dst in actual] | |||||
expected = [ | |||||
( | |||||
"swh:1:rel:0000000000000000000000000000000000000010", | |||||
"swh:1:rev:0000000000000000000000000000000000000009", | |||||
), | |||||
( | |||||
"swh:1:rev:0000000000000000000000000000000000000009", | |||||
"swh:1:rev:0000000000000000000000000000000000000003", | |||||
), | |||||
( | |||||
"swh:1:rev:0000000000000000000000000000000000000009", | |||||
"swh:1:dir:0000000000000000000000000000000000000008", | |||||
), | |||||
( | |||||
"swh:1:rev:0000000000000000000000000000000000000003", | |||||
"swh:1:dir:0000000000000000000000000000000000000002", | |||||
), | |||||
] | |||||
assert set(actual) == set(expected) | |||||
def test_visit_paths(graph): | def test_visit_paths(graph): | ||||
actual = list( | actual = list( | ||||
graph["swh:1:snp:0000000000000000000000000000000000000020"].visit_paths( | graph["swh:1:snp:0000000000000000000000000000000000000020"].visit_paths( | ||||
edges="snp:*,rev:*" | edges="snp:*,rev:*" | ||||
) | ) | ||||
) | ) | ||||
actual = [tuple(n.pid for n in path) for path in actual] | actual = [tuple(n.pid for n in path) for path in actual] | ||||
expected = [ | expected = [ | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |