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:
2026-10-15 09:48:47 +02:00
parent 96f4fa5a38
commit 0004e4b9bd
7 changed files with 114 additions and 2 deletions
+31
View File
@@ -550,3 +550,34 @@ async def test_the_live_socket_ends_when_its_client_goes(
await asyncio.sleep(0.05)
parked = [t for t in asyncio.all_tasks() if "Queue.get" in repr(t.get_coro())]
assert parked == []
def test_a_shared_node_in_use_is_retired_only_with_detach(
client: TestClient, superuser_token_headers: dict[str, str]
) -> None:
client.put(
f"{PREFIX}/shared", headers=superuser_token_headers, json=a_flow("shared")
)
client.put(
f"{PREFIX}/shared/nodes/sensor/source",
headers=superuser_token_headers,
json={"code": WORKING_NODE},
)
client.post(
f"{PREFIX}/shared/nodes/sensor/share",
headers=superuser_token_headers,
json={"lib_name": "reading"},
)
url = f"{PREFIX}/library/reading"
assert client.delete(url, headers=superuser_token_headers).status_code == 409
response = client.delete(f"{url}?detach=true", headers=superuser_token_headers)
assert response.status_code == 200
assert client.get(f"{PREFIX}/library", headers=superuser_token_headers).json() == []
source = client.get(
f"{PREFIX}/shared/nodes/sensor/source", headers=superuser_token_headers
)
assert source.json()["code"] == WORKING_NODE
client.delete(f"{PREFIX}/shared", headers=superuser_token_headers)