chore: migrate GRACE-Poly anchors to hierarchical dotted naming
Systematic rename of all semantic anchors (#region, [DEF], @RELATION) across 1400+ files — backend Python, frontend Svelte/TS, specs, docs: - Flat anchors become Namespace.Module.Entity - @RELATION references updated to match new anchor paths - Zero business logic changes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# #region Test.AppModule.WsEndpoint [C:3] [TYPE Module] [SEMANTICS test,app,ws,endpoint,logs]
|
||||
# @BRIEF Tests for app.py — websocket_endpoint: full flow, filters, disconnect, AWAITING_INPUT, terminal log, exceptions.
|
||||
# @RELATION BINDS_TO -> [AppModule]
|
||||
# @RELATION BINDS_TO -> [App.AppModule]
|
||||
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
@@ -56,7 +56,7 @@ def _make_task_manager_mock(task=None, logs=None):
|
||||
class TestWebSocketEndpointFull:
|
||||
"""websocket_endpoint — full flow."""
|
||||
|
||||
# #region test_auth_rejected_closes [C:2] [TYPE Function]
|
||||
# #region Test.AppModule.TestAuthRejectedCloses [C:2] [TYPE Function]
|
||||
@pytest.mark.asyncio
|
||||
async def test_auth_rejected_closes(self):
|
||||
from src.app import websocket_endpoint
|
||||
@@ -65,9 +65,9 @@ class TestWebSocketEndpointFull:
|
||||
await websocket_endpoint(ws, "task-1")
|
||||
ws.close.assert_called_once_with(code=4001, reason="Authentication required")
|
||||
ws.accept.assert_not_called()
|
||||
# #endregion test_auth_rejected_closes
|
||||
# #endregion Test.AppModule.TestAuthRejectedCloses
|
||||
|
||||
# #region test_accepts_and_sends_initial_status [C:2] [TYPE Function]
|
||||
# #region Test.AppModule.TestAcceptsAndSendsInitialStatus [C:2] [TYPE Function]
|
||||
@pytest.mark.asyncio
|
||||
async def test_accepts_and_sends_initial_status(self):
|
||||
from src.app import websocket_endpoint
|
||||
@@ -88,9 +88,9 @@ class TestWebSocketEndpointFull:
|
||||
await websocket_endpoint(ws, "task-1", source=None, level=None)
|
||||
ws.accept.assert_called_once()
|
||||
assert ws.send_json.call_count >= 2
|
||||
# #endregion test_accepts_and_sends_initial_status
|
||||
# #endregion Test.AppModule.TestAcceptsAndSendsInitialStatus
|
||||
|
||||
# #region test_source_filter [C:2] [TYPE Function]
|
||||
# #region Test.AppModule.TestSourceFilter [C:2] [TYPE Function]
|
||||
@pytest.mark.asyncio
|
||||
async def test_source_filter(self):
|
||||
from src.app import websocket_endpoint
|
||||
@@ -112,9 +112,9 @@ class TestWebSocketEndpointFull:
|
||||
await websocket_endpoint(ws, "task-1", source="plugin")
|
||||
msgs = [c[0][0].get("message") for c in ws.send_json.call_args_list if isinstance(c[0][0], dict)]
|
||||
assert "Superset" not in msgs
|
||||
# #endregion test_source_filter
|
||||
# #endregion Test.AppModule.TestSourceFilter
|
||||
|
||||
# #region test_level_filter [C:2] [TYPE Function]
|
||||
# #region Test.AppModule.TestLevelFilter [C:2] [TYPE Function]
|
||||
@pytest.mark.asyncio
|
||||
async def test_level_filter(self):
|
||||
from src.app import websocket_endpoint
|
||||
@@ -137,9 +137,9 @@ class TestWebSocketEndpointFull:
|
||||
msgs = [c[0][0].get("message") for c in ws.send_json.call_args_list if isinstance(c[0][0], dict)]
|
||||
assert "Debug" not in msgs
|
||||
assert "Info" in msgs
|
||||
# #endregion test_level_filter
|
||||
# #endregion Test.AppModule.TestLevelFilter
|
||||
|
||||
# #region test_disconnect_in_main_loop [C:2] [TYPE Function]
|
||||
# #region Test.AppModule.TestDisconnectInMainLoop [C:2] [TYPE Function]
|
||||
@pytest.mark.asyncio
|
||||
async def test_disconnect_in_main_loop(self):
|
||||
from src.app import websocket_endpoint
|
||||
@@ -159,9 +159,9 @@ class TestWebSocketEndpointFull:
|
||||
tm.subscribe_logs = sl; tm.subscribe_status = ss; mg.return_value = tm
|
||||
await websocket_endpoint(ws, "task-1")
|
||||
ws.accept.assert_called_once()
|
||||
# #endregion test_disconnect_in_main_loop
|
||||
# #endregion Test.AppModule.TestDisconnectInMainLoop
|
||||
|
||||
# #region test_awaiting_input_prompt [C:2] [TYPE Function]
|
||||
# #region Test.AppModule.TestAwaitingInputPrompt [C:2] [TYPE Function]
|
||||
@pytest.mark.asyncio
|
||||
async def test_awaiting_input_prompt(self):
|
||||
from src.app import websocket_endpoint
|
||||
@@ -182,9 +182,9 @@ class TestWebSocketEndpointFull:
|
||||
await websocket_endpoint(ws, "task-1")
|
||||
msgs = [c[0][0].get("message") for c in ws.send_json.call_args_list if isinstance(c[0][0], dict)]
|
||||
assert any("Task paused for user input" in (m or "") for m in msgs)
|
||||
# #endregion test_awaiting_input_prompt
|
||||
# #endregion Test.AppModule.TestAwaitingInputPrompt
|
||||
|
||||
# #region test_terminal_log_triggers_close [C:2] [TYPE Function]
|
||||
# #region Test.AppModule.TestTerminalLogTriggersClose [C:2] [TYPE Function]
|
||||
@pytest.mark.asyncio
|
||||
async def test_terminal_log_triggers_close(self):
|
||||
from src.app import websocket_endpoint
|
||||
@@ -204,13 +204,13 @@ class TestWebSocketEndpointFull:
|
||||
tm.subscribe_logs = sl; tm.subscribe_status = ss; mg.return_value = tm
|
||||
await websocket_endpoint(ws, "task-1")
|
||||
ws.accept.assert_called_once()
|
||||
# #endregion test_terminal_log_triggers_close
|
||||
# #endregion Test.AppModule.TestTerminalLogTriggersClose
|
||||
|
||||
|
||||
class TestMatchesFilters:
|
||||
"""matches_filters — extracted filter logic."""
|
||||
|
||||
# #region test_matches_filters [C:2] [TYPE Function]
|
||||
# #region Test.AppModule.TestMatchesFilters [C:2] [TYPE Function]
|
||||
def test_matches_filters(self):
|
||||
def mf(entry, source_filter=None, level_filter=None):
|
||||
lh = {"DEBUG": 0, "INFO": 1, "WARNING": 2, "ERROR": 3}
|
||||
@@ -230,13 +230,13 @@ class TestMatchesFilters:
|
||||
assert mf(E("other", "DEBUG"), level_filter="INFO") is False
|
||||
assert mf(E("superset_api", "WARNING"), source_filter="superset_api", level_filter="WARNING") is True
|
||||
assert mf(E(None, "INFO"), source_filter="plugin") is False
|
||||
# #endregion test_matches_filters
|
||||
# #endregion Test.AppModule.TestMatchesFilters
|
||||
|
||||
|
||||
class TestWebSocketMainLoopCoverage:
|
||||
"""Cover the main loop lines 654, 658, 660-677 — non-terminal status, log filter, log forwarding, terminal log message."""
|
||||
|
||||
# #region test_non_terminal_status_continue [C:2] [TYPE Function]
|
||||
# #region Test.AppModule.TestNonTerminalStatusContinue [C:2] [TYPE Function]
|
||||
@pytest.mark.asyncio
|
||||
async def test_non_terminal_status_continue(self):
|
||||
"""Non-terminal status (RUNNING) -> continue at line 654 is hit."""
|
||||
@@ -258,9 +258,9 @@ class TestWebSocketMainLoopCoverage:
|
||||
tm.subscribe_logs = sl; tm.subscribe_status = ss; mg.return_value = tm
|
||||
await websocket_endpoint(ws, "task-continue")
|
||||
ws.accept.assert_called_once()
|
||||
# #endregion test_non_terminal_status_continue
|
||||
# #endregion Test.AppModule.TestNonTerminalStatusContinue
|
||||
|
||||
# #region test_log_filter_continue_and_forward [C:2] [TYPE Function]
|
||||
# #region Test.AppModule.TestLogFilterContinueAndForward [C:2] [TYPE Function]
|
||||
@pytest.mark.asyncio
|
||||
async def test_log_filter_continue_and_forward(self):
|
||||
"""Log entry filtered out (line 658) + log entry forwarded (lines 660-662).
|
||||
@@ -297,9 +297,9 @@ class TestWebSocketMainLoopCoverage:
|
||||
# Pass source="plugin" so superset_api log entry is filtered out (line 658)
|
||||
await websocket_endpoint(ws, "task-filter", source="plugin")
|
||||
ws.accept.assert_called_once()
|
||||
# #endregion test_log_filter_continue_and_forward
|
||||
# #endregion Test.AppModule.TestLogFilterContinueAndForward
|
||||
|
||||
# #region test_terminal_log_message_detected [C:2] [TYPE Function]
|
||||
# #region Test.AppModule.TestTerminalLogMessageDetected [C:2] [TYPE Function]
|
||||
@pytest.mark.asyncio
|
||||
async def test_terminal_log_message_detected(self):
|
||||
"""Log entry with 'Task completed successfully' triggers delay at lines 669-677."""
|
||||
@@ -326,13 +326,13 @@ class TestWebSocketMainLoopCoverage:
|
||||
tm.subscribe_logs = sl; tm.subscribe_status = ss; mg.return_value = tm
|
||||
await websocket_endpoint(ws, "task-term-msg")
|
||||
ws.accept.assert_called_once()
|
||||
# #endregion test_terminal_log_message_detected
|
||||
# #endregion Test.AppModule.TestTerminalLogMessageDetected
|
||||
|
||||
|
||||
class TestWebSocketMainLoopExceptions:
|
||||
"""Generic Exception re-raise in WS main loops."""
|
||||
|
||||
# #region test_ws_endpoint_generic_exception [C:2] [TYPE Function]
|
||||
# #region Test.AppModule.TestWsEndpointGenericException [C:2] [TYPE Function]
|
||||
@pytest.mark.asyncio
|
||||
async def test_ws_endpoint_generic_exception(self):
|
||||
from src.app import websocket_endpoint
|
||||
@@ -351,9 +351,9 @@ class TestWebSocketMainLoopExceptions:
|
||||
tm.subscribe_logs = sl; tm.subscribe_status = ss; mg.return_value = tm
|
||||
with pytest.raises(Exception):
|
||||
await websocket_endpoint(ws, "task-1")
|
||||
# #endregion test_ws_endpoint_generic_exception
|
||||
# #endregion Test.AppModule.TestWsEndpointGenericException
|
||||
|
||||
# #region test_task_events_generic_exception [C:2] [TYPE Function]
|
||||
# #region Test.AppModule.TestTaskEventsGenericException [C:2] [TYPE Function]
|
||||
@pytest.mark.asyncio
|
||||
async def test_task_events_generic_exception(self):
|
||||
from src.app import task_events_websocket
|
||||
@@ -371,9 +371,9 @@ class TestWebSocketMainLoopExceptions:
|
||||
mg.return_value = tm
|
||||
with pytest.raises(RuntimeError, match="crash"):
|
||||
await task_events_websocket(ws)
|
||||
# #endregion test_task_events_generic_exception
|
||||
# #endregion Test.AppModule.TestTaskEventsGenericException
|
||||
|
||||
# #region test_maintenance_events_generic_exception [C:2] [TYPE Function]
|
||||
# #region Test.AppModule.TestMaintenanceEventsGenericException [C:2] [TYPE Function]
|
||||
@pytest.mark.asyncio
|
||||
async def test_maintenance_events_generic_exception(self):
|
||||
from src.app import maintenance_events_websocket
|
||||
@@ -390,9 +390,9 @@ class TestWebSocketMainLoopExceptions:
|
||||
mg.return_value = tm
|
||||
with pytest.raises(ValueError, match="bad"):
|
||||
await maintenance_events_websocket(ws)
|
||||
# #endregion test_maintenance_events_generic_exception
|
||||
# #endregion Test.AppModule.TestMaintenanceEventsGenericException
|
||||
|
||||
# #region test_dataset_ws_generic_exception [C:2] [TYPE Function]
|
||||
# #region Test.AppModule.TestDatasetWsGenericException [C:2] [TYPE Function]
|
||||
@pytest.mark.asyncio
|
||||
async def test_dataset_ws_generic_exception(self):
|
||||
from src.app import dataset_websocket_endpoint
|
||||
@@ -409,5 +409,5 @@ class TestWebSocketMainLoopExceptions:
|
||||
mg.return_value = tm
|
||||
await dataset_websocket_endpoint(ws, "env-1")
|
||||
ws.accept.assert_called_once()
|
||||
# #endregion test_dataset_ws_generic_exception
|
||||
# #endregion Test.AppModule.TestDatasetWsGenericException
|
||||
# #endregion Test.AppModule.WsEndpoint
|
||||
|
||||
Reference in New Issue
Block a user