Skip to content

Commit

Permalink
Update links keyword to edges in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchnegus committed Feb 3, 2025
1 parent 66321dc commit 1e09a79
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/firewheel/control/dependency_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def has_cycles(self):
def get_graph_json(self):
"""
Return a JSON formatted string representation of the graph. The
representation is based on the D3 nodes-links format with links
representation is based on the D3 nodes-edges format with edges
referencing node ID rather than list position.
Returns:
Expand Down
20 changes: 10 additions & 10 deletions src/firewheel/tests/unit/control/test_dependency_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_insert_entity(self):
{"id": "test_provides1", "type": "constraint", "grouping": 0},
{"id": "test_provides2", "type": "constraint", "grouping": 0},
],
"links": [
"edges": [
{"source": "test_depends1", "target": 1},
{"source": "test_depends2", "target": 1},
{"source": 1, "target": "test_provides1"},
Expand Down Expand Up @@ -76,7 +76,7 @@ def test_insert_entity_twice(self):
{"id": "test_provides1", "type": "constraint", "grouping": 0},
{"id": "test_provides2", "type": "constraint", "grouping": 0},
],
"links": [
"edges": [
{"source": "test_depends1", "target": 1},
{"source": "test_depends2", "target": 1},
{"source": "test_depends1", "target": 6},
Expand Down Expand Up @@ -116,7 +116,7 @@ def test_associate_entities(self):
{"id": "test_provides1", "type": "constraint", "grouping": 0},
{"id": "test_provides2", "type": "constraint", "grouping": 0},
],
"links": [
"edges": [
{"source": "test_depends1", "target": 1},
{"source": 1, "target": "test_provides1"},
{"source": 4, "target": "test_provides2"},
Expand Down Expand Up @@ -194,7 +194,7 @@ def test_insert_one_element_cycle(self):
{"id": 1, "type": "entity", "grouping": 0},
{"id": "test_depends_cycler", "type": "constraint", "grouping": 0},
],
"links": [
"edges": [
{"source": "test_depends_cycler", "target": 1},
{"source": 1, "target": "test_depends_cycler"},
],
Expand Down Expand Up @@ -223,7 +223,7 @@ def test_insert_two_element_cycle(self):
{"id": "test_depends_cycler", "type": "constraint", "grouping": 0},
{"id": "test_provides_cycler", "type": "constraint", "grouping": 0},
],
"links": [
"edges": [
{"source": "test_depends_cycler", "target": 1},
{"source": 1, "target": "test_provides_cycler"},
{"source": "test_provides_cycler", "target": 4},
Expand Down Expand Up @@ -256,7 +256,7 @@ def test_zero_zero_in_degree_constraints(self):
{"id": "c1", "type": "constraint", "grouping": 0},
{"id": "c2", "type": "constraint", "grouping": 0},
],
"links": [
"edges": [
{"source": 1, "target": "c1"},
{"source": "c1", "target": 3},
{"source": 3, "target": "c2"},
Expand Down Expand Up @@ -291,7 +291,7 @@ def test_one_zero_in_degree_constraints(self):
{"id": "c2", "type": "constraint", "grouping": 0},
{"id": "c3", "type": "constraint", "grouping": 0},
],
"links": [
"edges": [
{"source": 1, "target": "c1"},
{"source": "c1", "target": 3},
{"source": 3, "target": "c2"},
Expand Down Expand Up @@ -328,7 +328,7 @@ def test_two_zero_in_degree_constraints(self):
{"id": "c3", "type": "constraint", "grouping": 0},
{"id": "c4", "type": "constraint", "grouping": 0},
],
"links": [
"edges": [
{"source": 1, "target": "c1"},
{"source": "c1", "target": 4},
{"source": 4, "target": "c2"},
Expand Down Expand Up @@ -362,7 +362,7 @@ def test_ordered_entity_list_with_cycle(self):
{"id": "test_depends_cycler", "type": "constraint", "grouping": 0},
{"id": "test_provides_cycler", "type": "constraint", "grouping": 0},
],
"links": [
"edges": [
{"source": "test_depends_cycler", "target": 1},
{"source": 1, "target": "test_provides_cycler"},
{"source": "test_provides_cycler", "target": 4},
Expand Down Expand Up @@ -430,7 +430,7 @@ def test_ordered_entity_list(self):
{"id": 13, "type": "entity", "grouping": 0},
{"id": 14, "type": "entity", "grouping": 0},
],
"links": [
"edges": [
{"source": 1, "target": "c1"},
{"source": "c1", "target": 3},
{"source": 3, "target": "c2"},
Expand Down
30 changes: 15 additions & 15 deletions src/firewheel/tests/unit/control/test_utils_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ def test_empty(self):
with self.assertRaises(ValueError):
compare_graph_structures({}, {})
with self.assertRaises(ValueError):
compare_graph_structures({"nodes": [], "links": []}, {})
compare_graph_structures({"nodes": [], "edges": []}, {})

def test_simple_equal(self):
a = {
"nodes": [{"id": 1}, {"id": 2}],
"links": [{"source": 1, "target": 2}],
"edges": [{"source": 1, "target": 2}],
"other1": "val1",
"other2": "val2",
}
b = {
"nodes": [{"id": 1}, {"id": 2}],
"links": [{"source": 1, "target": 2}],
"edges": [{"source": 1, "target": 2}],
"other1": "val1",
"other2": "val2",
}
Expand All @@ -37,13 +37,13 @@ def test_simple_equal(self):
def test_equal_odd_lists(self):
a = {
"nodes": [{"key1": 1}, {"key2": 2}],
"links": [{"k1": 1, "k2": 2}],
"edges": [{"k1": 1, "k2": 2}],
"other1": "val1",
"other2": "val2",
}
b = {
"nodes": [{"key1": 1}, {"key2": 2}],
"links": [{"k1": 1, "k2": 2}],
"edges": [{"k1": 1, "k2": 2}],
"other1": "val1",
"other2": "val2",
}
Expand All @@ -53,19 +53,19 @@ def test_equal_odd_lists(self):
def test_different_nodes(self):
a = {
"nodes": [{"id": 1}, {"id": 2}],
"links": [{"source": 1, "target": 2}],
"edges": [{"source": 1, "target": 2}],
"other1": "val1",
"other2": "val2",
}
b = {
"nodes": [{"id": 1}, {"id": 3}],
"links": [{"source": 1, "target": 3}],
"edges": [{"source": 1, "target": 3}],
"other1": "val1",
"other2": "val2",
}
c = {
"nodes": [{"id": 1}],
"links": [{"source": 1, "target": 2}],
"edges": [{"source": 1, "target": 2}],
"other1": "val1",
"other2": "val2",
}
Expand All @@ -77,22 +77,22 @@ def test_different_nodes(self):
self.assertFalse(compare_graph_structures(b, c))
self.assertFalse(compare_graph_structures(c, b))

def test_different_links(self):
def test_different_edges(self):
a = {
"nodes": [{"id": 1}, {"id": 2}],
"links": [{"source": 1, "target": 2}],
"edges": [{"source": 1, "target": 2}],
"other1": "val1",
"other2": "val2",
}
b = {
"nodes": [{"id": 1}, {"id": 2}],
"links": [],
"edges": [],
"other1": "val1",
"other2": "val2",
}
c = {
"nodes": [{"id": 1}, {"id": 2}],
"links": [{"source": 1, "target": 2}, {"source": 2, "target": 1}],
"edges": [{"source": 1, "target": 2}, {"source": 2, "target": 1}],
"other1": "val1",
"other2": "val2",
}
Expand All @@ -107,19 +107,19 @@ def test_different_links(self):
def test_different_other(self):
a = {
"nodes": [{"id": 1}, {"id": 2}],
"links": [{"source": 1, "target": 2}],
"edges": [{"source": 1, "target": 2}],
"other1": "val1",
"other2": "val2",
}
b = {
"nodes": [{"id": 1}, {"id": 2}],
"links": [{"source": 1, "target": 2}],
"edges": [{"source": 1, "target": 2}],
"other1": "other_val",
"other2": "val2",
}
c = {
"nodes": [{"id": 1}, {"id": 2}],
"links": [{"source": 1, "target": 2}],
"edges": [{"source": 1, "target": 2}],
"other1": "val1",
}

Expand Down
16 changes: 8 additions & 8 deletions src/firewheel/tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def cleanup_repo_db(repository_db, repo_client):


def compare_graph_structures(a, b):
if "nodes" not in a or "links" not in a:
if "nodes" not in a or "edges" not in a:
raise ValueError("First structure is not a valid graph structure.")
if "nodes" not in b or "links" not in b:
if "nodes" not in b or "edges" not in b:
raise ValueError("Second structure is not a valid graph structure.")

for n in a["nodes"]:
Expand All @@ -48,33 +48,33 @@ def compare_graph_structures(a, b):
if not found:
return False

for n in a["links"]:
for n in a["edges"]:
found = False
for m in b["links"]:
for m in b["edges"]:
if n == m:
found = True
break
if not found:
return False
for m in b["links"]:
for m in b["edges"]:
found = False
for n in a["links"]:
for n in a["edges"]:
if n == m:
found = True
break
if not found:
return False

for key in a:
if key in ("nodes", "links"):
if key in ("nodes", "edges"):
continue
try:
if a[key] != b[key]:
return False
except KeyError:
return False
for key in b:
if key in ("nodes", "links"):
if key in ("nodes", "edges"):
continue
try:
# No need to compare here--if the key exists in both a and b, then
Expand Down

0 comments on commit 1e09a79

Please sign in to comment.