Skip to content

Commit

Permalink
nit #11570
Browse files Browse the repository at this point in the history
  • Loading branch information
chrabyrd committed Nov 14, 2024
1 parent d802939 commit 92a69de
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions arches/app/models/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2449,6 +2449,7 @@ def update_from_editable_future_graph(self, editable_future_graph):
if card["source_identifier_id"]
}

# update cards_x_nodes_x_widgets
for serialized_card_x_node_x_widget in serialized_editable_future_graph[
"cards_x_nodes_x_widgets"
]:
Expand All @@ -2470,6 +2471,7 @@ def update_from_editable_future_graph(self, editable_future_graph):
if updated_node_id:
serialized_card_x_node_x_widget["node_id"] = updated_node_id

# update cards
for serialized_card in serialized_editable_future_graph["cards"]:
if serialized_card["source_identifier_id"]:
serialized_card["cardid"] = serialized_card["source_identifier_id"]
Expand All @@ -2483,6 +2485,7 @@ def update_from_editable_future_graph(self, editable_future_graph):

serialized_card["graph_id"] = serialized_source_graph["graphid"]

# update nodes
for serialized_node in serialized_editable_future_graph["nodes"]:
if serialized_node["source_identifier_id"]:
serialized_node["nodeid"] = serialized_node["source_identifier_id"]
Expand All @@ -2496,6 +2499,7 @@ def update_from_editable_future_graph(self, editable_future_graph):

serialized_node["graph_id"] = serialized_source_graph["graphid"]

# update nodegroups
for serialized_nodegroup in serialized_editable_future_graph["nodegroups"]:
updated_nodegroup_id = node_id_to_node_source_identifier_id.get(
serialized_nodegroup["nodegroupid"]
Expand All @@ -2509,6 +2513,7 @@ def update_from_editable_future_graph(self, editable_future_graph):
if updated_nodegroup_id:
serialized_nodegroup["parentnodegroup_id"] = updated_parent_nodegroup_id

# update edges
for serialized_edge in serialized_editable_future_graph["edges"]:
if serialized_edge["source_identifier_id"]:
serialized_edge["edgeid"] = serialized_edge["source_identifier_id"]
Expand All @@ -2528,6 +2533,7 @@ def update_from_editable_future_graph(self, editable_future_graph):

serialized_edge["graph_id"] = serialized_source_graph["graphid"]

# update root node
serialized_editable_future_graph["root"]["graph_id"] = serialized_source_graph[
"graphid"
]
Expand All @@ -2536,13 +2542,15 @@ def update_from_editable_future_graph(self, editable_future_graph):
)
serialized_editable_future_graph["root"]["source_identifier_id"] = None

# update graph data
serialized_editable_future_graph["graphid"] = serialized_source_graph["graphid"]
serialized_editable_future_graph["has_unpublished_changes"] = False
serialized_editable_future_graph["resource_instance_lifecycle_id"] = (
serialized_source_graph["resource_instance_lifecycle_id"]
)
serialized_editable_future_graph["source_identifier_id"] = None

# update permissions
serialized_editable_future_graph["group_permissions"] = {
key: value
for key, value in serialized_source_graph["group_permissions"].items()
Expand Down
12 changes: 11 additions & 1 deletion tests/models/graph_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,9 @@ def test_deleting_source_graph_deletes_editable_future_graph_and_all_related_mod
edge_count_before = models.Edge.objects.count()
card_count_before = models.CardModel.objects.count()
card_x_node_x_widget_count_before = models.CardXNodeXWidget.objects.count()
resource_2_resource_constraints_count_before = (
models.Resource2ResourceConstraint.objects.count()
)

source_graph = Graph.new(name="TEST RESOURCE", is_resource=True, author="TEST")
source_graph.save()
Expand All @@ -1786,6 +1789,9 @@ def test_deleting_source_graph_deletes_editable_future_graph_and_all_related_mod
edge_count_after = models.Edge.objects.count()
card_count_after = models.CardModel.objects.count()
card_x_node_x_widget_count_after = models.CardXNodeXWidget.objects.count()
resource_2_resource_constraints_count_after = (
models.Resource2ResourceConstraint.objects.count()
)

self.assertEqual(nodegroup_count_before, nodegroup_count_after)
self.assertEqual(node_count_before, node_count_after)
Expand All @@ -1794,6 +1800,10 @@ def test_deleting_source_graph_deletes_editable_future_graph_and_all_related_mod
self.assertEqual(
card_x_node_x_widget_count_before, card_x_node_x_widget_count_after
)
self.assertEqual(
resource_2_resource_constraints_count_before,
resource_2_resource_constraints_count_after,
)

def test_revert_editable_future_graph(self):
source_graph = Graph.new(name="TEST RESOURCE", is_resource=True, author="TEST")
Expand Down Expand Up @@ -2160,7 +2170,7 @@ def test_update_from_editable_future_graph_does_not_affect_resources(self):
self.assertEqual(serialized_resource, serialized_resource_from_database)
self.assertEqual(serialized_tile, serialized_tile_from_database)

def test_foo(self):
def test_placing_node_in_separate_card_does_not_pollute_database(self):
source_graph = Graph.new(name="TEST RESOURCE", is_resource=True, author="TEST")
source_graph.save()
editable_future_graph = source_graph.create_editable_future_graph()
Expand Down

0 comments on commit 92a69de

Please sign in to comment.