Duplicate flow: references to its own messages under its own name follow the copy
This commit is contained in:
@@ -699,6 +699,8 @@ class FlowStore:
|
||||
"origin": None,
|
||||
}
|
||||
)
|
||||
# Its own messages named with its own name are the copy's now.
|
||||
self._retarget(copy, f"{name}.", f"{new_name}.")
|
||||
path = self._draft_file(new_name)
|
||||
path.parent.mkdir(parents=True)
|
||||
path.write_text(copy.model_dump_json(indent=2) + "\n")
|
||||
|
||||
@@ -184,7 +184,9 @@ def test_renaming_carries_the_draft_and_repoints_other_drafts(store: FlowStore):
|
||||
|
||||
|
||||
def test_a_duplicate_is_a_local_draft_of_what_the_editor_shows(store: FlowStore):
|
||||
store.write_flow(a_flow(title="Warm").model_copy(update={"origin": FlowOrigin()}))
|
||||
flow = a_flow(title="Warm").model_copy(update={"origin": FlowOrigin()})
|
||||
flow.nodes.append(NodeDef(id="reader", requires=[MessageSpec(name="heating.temp")]))
|
||||
store.write_flow(flow)
|
||||
store.write_node_source("heating", "sensor", SOURCE)
|
||||
store.write_node_source("heating", "sensor", EDITED, draft=True)
|
||||
store.write_enabled("heating", False)
|
||||
@@ -193,6 +195,7 @@ def test_a_duplicate_is_a_local_draft_of_what_the_editor_shows(store: FlowStore)
|
||||
|
||||
assert (copy.name, copy.title, copy.version) == ("heating_copy", "Warm (copy)", 1)
|
||||
assert copy.origin is None
|
||||
assert copy.nodes[1].requires[0].name == "heating_copy.temp"
|
||||
assert store.has_draft("heating_copy") and not store.is_published("heating_copy")
|
||||
assert store.read_node_source("heating_copy", "sensor", draft=True) == EDITED
|
||||
assert not (store.root / "heating_copy" / "runtime.json").exists()
|
||||
|
||||
Reference in New Issue
Block a user