From 728332f8f75f06884bfd61eacd5a7ab03e06e886 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 17 Mar 2026 21:14:34 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85(backend)=20assert=20document=20path?= =?UTF-8?q?=20can=20not=20change=20during=20API=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want to assert on every succesful update test that the document path has not change. --- .../tests/documents/test_api_documents_update.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/backend/core/tests/documents/test_api_documents_update.py b/src/backend/core/tests/documents/test_api_documents_update.py index a08ec2c6..ed57e320 100644 --- a/src/backend/core/tests/documents/test_api_documents_update.py +++ b/src/backend/core/tests/documents/test_api_documents_update.py @@ -330,6 +330,7 @@ def test_api_documents_update_authenticated_no_websocket(settings): ws_resp = responses.get(endpoint_url, json={"count": 0, "exists": False}) assert cache.get(f"docs:no-websocket:{document.id}") is None + old_path = document.path response = client.put( f"/api/v1.0/documents/{document.id!s}/", @@ -338,6 +339,8 @@ def test_api_documents_update_authenticated_no_websocket(settings): ) assert response.status_code == 200 + document.refresh_from_db() + assert document.path == old_path assert cache.get(f"docs:no-websocket:{document.id}") == session_key assert ws_resp.call_count == 1 @@ -446,6 +449,7 @@ def test_api_documents_update_user_connected_to_websocket(settings): ws_resp = responses.get(endpoint_url, json={"count": 3, "exists": True}) assert cache.get(f"docs:no-websocket:{document.id}") is None + old_path = document.path response = client.put( f"/api/v1.0/documents/{document.id!s}/", @@ -453,6 +457,9 @@ def test_api_documents_update_user_connected_to_websocket(settings): format="json", ) assert response.status_code == 200 + + document.refresh_from_db() + assert document.path == old_path assert cache.get(f"docs:no-websocket:{document.id}") is None assert ws_resp.call_count == 1 @@ -486,6 +493,7 @@ def test_api_documents_update_websocket_server_unreachable_fallback_to_no_websoc ws_resp = responses.get(endpoint_url, status=500) assert cache.get(f"docs:no-websocket:{document.id}") is None + old_path = document.path response = client.put( f"/api/v1.0/documents/{document.id!s}/", @@ -494,6 +502,8 @@ def test_api_documents_update_websocket_server_unreachable_fallback_to_no_websoc ) assert response.status_code == 200 + document.refresh_from_db() + assert document.path == old_path assert cache.get(f"docs:no-websocket:{document.id}") == session_key assert ws_resp.call_count == 1 @@ -605,6 +615,7 @@ def test_api_documents_update_force_websocket_param_to_true(settings): ws_resp = responses.get(endpoint_url, status=500) assert cache.get(f"docs:no-websocket:{document.id}") is None + old_path = document.path response = client.put( f"/api/v1.0/documents/{document.id!s}/", @@ -613,6 +624,8 @@ def test_api_documents_update_force_websocket_param_to_true(settings): ) assert response.status_code == 200 + document.refresh_from_db() + assert document.path == old_path assert cache.get(f"docs:no-websocket:{document.id}") is None assert ws_resp.call_count == 0 @@ -643,6 +656,7 @@ def test_api_documents_update_feature_flag_disabled(settings): ws_resp = responses.get(endpoint_url, status=500) assert cache.get(f"docs:no-websocket:{document.id}") is None + old_path = document.path response = client.put( f"/api/v1.0/documents/{document.id!s}/", @@ -651,6 +665,8 @@ def test_api_documents_update_feature_flag_disabled(settings): ) assert response.status_code == 200 + document.refresh_from_db() + assert document.path == old_path assert cache.get(f"docs:no-websocket:{document.id}") is None assert ws_resp.call_count == 0