Retire a shared node in use with ?detach=true
DELETE /flows/library/{name} still answers 409 while nodes use the source.
With detach=true each of them keeps a copy of the code, in the published
flow and the draft, the source is deleted and the running users rebuild.
This commit is contained in:
@@ -120,3 +120,27 @@ def test_unsharing_takes_a_private_copy_back(store: FlowStore):
|
||||
def test_a_missing_shared_source_is_reported(store: FlowStore):
|
||||
with pytest.raises(LibNotFound):
|
||||
store.read_lib_source("nothing_here")
|
||||
|
||||
|
||||
def test_retiring_a_shared_source_leaves_each_user_a_copy(store: FlowStore):
|
||||
store.write_flow(a_flow())
|
||||
store.write_node_source("heating", "sensor", SOURCE)
|
||||
store.share_node("heating", "sensor", "read_temp")
|
||||
store.publish_flow("heating", store.read_flow("heating", draft=True).version)
|
||||
version = store.read_flow("heating").version
|
||||
# Shared in a draft that was never published.
|
||||
cooling = a_flow("cooling")
|
||||
cooling.nodes[0].source_ref = "read_temp"
|
||||
store.write_draft(cooling, 0)
|
||||
|
||||
store.detach_lib("read_temp")
|
||||
|
||||
assert store.list_lib() == []
|
||||
heating = store.read_flow("heating")
|
||||
assert heating.nodes[0].source_ref is None
|
||||
assert heating.version == version + 1
|
||||
assert store.read_node_source("heating", "sensor") == SOURCE
|
||||
# What runs is the same code, so there is nothing to publish.
|
||||
assert not store.has_draft("heating")
|
||||
assert store.read_flow("cooling", draft=True).nodes[0].source_ref is None
|
||||
assert store.read_node_source("cooling", "sensor", draft=True) == SOURCE
|
||||
|
||||
Reference in New Issue
Block a user