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,5 +1,5 @@
|
||||
# #region test_log_persistence [C:2] [TYPE Module]
|
||||
# @RELATION BINDS_TO -> SrcRoot
|
||||
# #region Test.LogPersistence.Test.Log.Persistence [C:2] [TYPE Module]
|
||||
# @RELATION BINDS_TO -> Init.SrcRoot
|
||||
# @SEMANTICS: test, log, persistence, unit_test
|
||||
# @PURPOSE: Unit tests for TaskLogPersistenceService.
|
||||
# @LAYER Tests
|
||||
@@ -15,13 +15,13 @@ from src.core.task_manager.persistence import TaskLogPersistenceService
|
||||
from src.models.mapping import Base
|
||||
|
||||
|
||||
# #region TestLogPersistence [C:2] [TYPE Class]
|
||||
# @RELATION BINDS_TO -> test_log_persistence
|
||||
# #region Test.LogPersistence.TestLogPersistenceClass [C:2] [TYPE Class]
|
||||
# @RELATION BINDS_TO -> Test.LogPersistence.Test.Log.Persistence
|
||||
# @PURPOSE: Test suite for TaskLogPersistenceService.
|
||||
# @TEST_DATA: log_entry -> {"task_id": "test-task-1", "level": "INFO", "source": "test_source", "message": "Test message"}
|
||||
class TestLogPersistence:
|
||||
|
||||
# #region setup_class [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.SetupClass [C:2] [TYPE Function]
|
||||
# @PURPOSE: Setup test database and service instance.
|
||||
# @PRE: None.
|
||||
# @POST: In-memory database and service instance created.
|
||||
@@ -34,9 +34,9 @@ class TestLogPersistence:
|
||||
Base.metadata.create_all(bind=cls.engine)
|
||||
cls.TestSessionLocal = sessionmaker(bind=cls.engine)
|
||||
cls.service = TaskLogPersistenceService()
|
||||
# #endregion setup_class
|
||||
# #endregion Test.LogPersistence.SetupClass
|
||||
|
||||
# #region teardown_class [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TeardownClass [C:2] [TYPE Function]
|
||||
# @PURPOSE: Clean up test database.
|
||||
# @PRE: None.
|
||||
# @POST: Database disposed.
|
||||
@@ -44,9 +44,9 @@ class TestLogPersistence:
|
||||
def teardown_class(cls):
|
||||
"""Dispose of the database engine."""
|
||||
cls.engine.dispose()
|
||||
# #endregion teardown_class
|
||||
# #endregion Test.LogPersistence.TeardownClass
|
||||
|
||||
# #region setup_method [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.SetupMethod [C:2] [TYPE Function]
|
||||
# @PURPOSE: Setup for each test method — clean task_logs table.
|
||||
# @PRE: None.
|
||||
# @POST: task_logs table is empty.
|
||||
@@ -66,7 +66,7 @@ class TestLogPersistence:
|
||||
session.query(TaskLogRecord).delete()
|
||||
session.commit()
|
||||
session.close()
|
||||
# #endregion setup_method
|
||||
# #endregion Test.LogPersistence.SetupMethod
|
||||
|
||||
def _patched(self, method_name):
|
||||
"""Helper: returns a patch context for TasksSessionLocal."""
|
||||
@@ -75,7 +75,7 @@ class TestLogPersistence:
|
||||
self.TestSessionLocal
|
||||
)
|
||||
|
||||
# #region test_add_logs_single [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestAddLogsSingle [C:2] [TYPE Function]
|
||||
# @PURPOSE: Test adding a single log entry.
|
||||
# @PRE: Service and session initialized.
|
||||
# @POST: Log entry persisted to database.
|
||||
@@ -101,9 +101,9 @@ class TestLogPersistence:
|
||||
assert result.level == "INFO"
|
||||
assert result.source == "test_source"
|
||||
assert result.message == "Test message"
|
||||
# #endregion test_add_logs_single
|
||||
# #endregion Test.LogPersistence.TestAddLogsSingle
|
||||
|
||||
# #region test_add_logs_batch [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestAddLogsBatch [C:2] [TYPE Function]
|
||||
# @PURPOSE: Test adding multiple log entries in batch.
|
||||
# @PRE: Service and session initialized.
|
||||
# @POST: All log entries persisted to database.
|
||||
@@ -124,9 +124,9 @@ class TestLogPersistence:
|
||||
session.close()
|
||||
|
||||
assert len(results) == 3
|
||||
# #endregion test_add_logs_batch
|
||||
# #endregion Test.LogPersistence.TestAddLogsBatch
|
||||
|
||||
# #region test_add_logs_empty [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestAddLogsEmpty [C:2] [TYPE Function]
|
||||
# @PURPOSE: Test adding empty log list (should be no-op).
|
||||
# @PRE: Service initialized.
|
||||
# @POST: No logs added.
|
||||
@@ -140,9 +140,9 @@ class TestLogPersistence:
|
||||
results = session.query(TaskLogRecord).filter_by(task_id="test-task-X").all()
|
||||
session.close()
|
||||
assert len(results) == 0
|
||||
# #endregion test_add_logs_empty
|
||||
# #endregion Test.LogPersistence.TestAddLogsEmpty
|
||||
|
||||
# #region test_get_logs_by_task_id [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestGetLogsByTaskId [C:2] [TYPE Function]
|
||||
# @PURPOSE: Test retrieving logs by task ID.
|
||||
# @PRE: Service and session initialized, logs exist.
|
||||
# @POST: Returns logs for the specified task.
|
||||
@@ -160,9 +160,9 @@ class TestLogPersistence:
|
||||
|
||||
assert len(logs) == 5
|
||||
assert all(log.task_id == "test-task-3" for log in logs)
|
||||
# #endregion test_get_logs_by_task_id
|
||||
# #endregion Test.LogPersistence.TestGetLogsByTaskId
|
||||
|
||||
# #region test_get_logs_with_filters [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestGetLogsWithFilters [C:2] [TYPE Function]
|
||||
# @PURPOSE: Test retrieving logs with level and source filters.
|
||||
# @PRE: Service and session initialized, logs exist.
|
||||
# @POST: Returns filtered logs.
|
||||
@@ -187,9 +187,9 @@ class TestLogPersistence:
|
||||
api_logs = self.service.get_logs("test-task-4", LogFilter(source="api"))
|
||||
assert len(api_logs) == 2
|
||||
assert all(log.source == "api" for log in api_logs)
|
||||
# #endregion test_get_logs_with_filters
|
||||
# #endregion Test.LogPersistence.TestGetLogsWithFilters
|
||||
|
||||
# #region test_get_logs_with_pagination [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestGetLogsWithPagination [C:2] [TYPE Function]
|
||||
# @PURPOSE: Test retrieving logs with pagination.
|
||||
# @PRE: Service and session initialized, logs exist.
|
||||
# @POST: Returns paginated logs.
|
||||
@@ -209,9 +209,9 @@ class TestLogPersistence:
|
||||
with self._patched("get_logs"):
|
||||
page2 = self.service.get_logs("test-task-5", LogFilter(limit=10, offset=10))
|
||||
assert len(page2) == 5
|
||||
# #endregion test_get_logs_with_pagination
|
||||
# #endregion Test.LogPersistence.TestGetLogsWithPagination
|
||||
|
||||
# #region test_get_logs_with_search [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestGetLogsWithSearch [C:2] [TYPE Function]
|
||||
# @PURPOSE: Test retrieving logs with search query.
|
||||
# @PRE: Service and session initialized, logs exist.
|
||||
# @POST: Returns logs matching search query.
|
||||
@@ -229,9 +229,9 @@ class TestLogPersistence:
|
||||
auth_logs = self.service.get_logs("test-task-6", LogFilter(search="authentication"))
|
||||
assert len(auth_logs) == 1
|
||||
assert "authentication" in auth_logs[0].message.lower()
|
||||
# #endregion test_get_logs_with_search
|
||||
# #endregion Test.LogPersistence.TestGetLogsWithSearch
|
||||
|
||||
# #region test_get_log_stats [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestGetLogStats [C:2] [TYPE Function]
|
||||
# @PURPOSE: Test retrieving log statistics.
|
||||
# @PRE: Service and session initialized, logs exist.
|
||||
# @POST: Returns LogStats model with counts by level and source.
|
||||
@@ -256,9 +256,9 @@ class TestLogPersistence:
|
||||
assert stats.by_level["ERROR"] == 1
|
||||
assert stats.by_source["api"] == 3
|
||||
assert stats.by_source["storage"] == 1
|
||||
# #endregion test_get_log_stats
|
||||
# #endregion Test.LogPersistence.TestGetLogStats
|
||||
|
||||
# #region test_get_sources [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestGetSources [C:2] [TYPE Function]
|
||||
# @PURPOSE: Test retrieving unique log sources.
|
||||
# @PRE: Service and session initialized, logs exist.
|
||||
# @POST: Returns list of unique sources.
|
||||
@@ -279,9 +279,9 @@ class TestLogPersistence:
|
||||
assert "api" in sources
|
||||
assert "storage" in sources
|
||||
assert "git" in sources
|
||||
# #endregion test_get_sources
|
||||
# #endregion Test.LogPersistence.TestGetSources
|
||||
|
||||
# #region test_delete_logs_for_task [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestDeleteLogsForTask [C:2] [TYPE Function]
|
||||
# @PURPOSE: Test deleting logs by task ID.
|
||||
# @PRE: Service and session initialized, logs exist.
|
||||
# @POST: Logs for the task are deleted.
|
||||
@@ -307,9 +307,9 @@ class TestLogPersistence:
|
||||
with self._patched("get_logs"):
|
||||
logs_after = self.service.get_logs("test-task-9", LogFilter())
|
||||
assert len(logs_after) == 0
|
||||
# #endregion test_delete_logs_for_task
|
||||
# #endregion Test.LogPersistence.TestDeleteLogsForTask
|
||||
|
||||
# #region test_delete_logs_for_tasks [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestDeleteLogsForTasks [C:2] [TYPE Function]
|
||||
# @PURPOSE: Test deleting logs for multiple tasks.
|
||||
# @PRE: Service and session initialized, logs exist.
|
||||
# @POST: Logs for all specified tasks are deleted.
|
||||
@@ -331,9 +331,9 @@ class TestLogPersistence:
|
||||
session.close()
|
||||
assert len(remaining) == 1
|
||||
assert remaining[0].task_id == "multi-3"
|
||||
# #endregion test_delete_logs_for_tasks
|
||||
# #endregion Test.LogPersistence.TestDeleteLogsForTasks
|
||||
|
||||
# #region test_delete_logs_for_tasks_empty [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestDeleteLogsForTasksEmpty [C:2] [TYPE Function]
|
||||
# @PURPOSE: Test deleting with empty list (no-op).
|
||||
# @PRE: Service initialized.
|
||||
# @POST: No error, no deletion.
|
||||
@@ -341,9 +341,9 @@ class TestLogPersistence:
|
||||
"""Test deleting with empty list is a no-op."""
|
||||
with self._patched("delete_logs_for_tasks"):
|
||||
self.service.delete_logs_for_tasks([]) # Should not raise
|
||||
# #endregion test_delete_logs_for_tasks_empty
|
||||
# #endregion Test.LogPersistence.TestDeleteLogsForTasksEmpty
|
||||
|
||||
# #region test_add_logs_db_error_rollback [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestAddLogsDbErrorRollback [C:2] [TYPE Function]
|
||||
# @PURPOSE: add_logs rollbacks on database error.
|
||||
def test_add_logs_db_error_rollback(self):
|
||||
entry = LogEntry(timestamp=datetime.now(UTC), level="INFO", source="test", message="will fail")
|
||||
@@ -362,9 +362,9 @@ class TestLogPersistence:
|
||||
count = session.query(TaskLogRecord).filter_by(task_id="test-task-1").count()
|
||||
session.close()
|
||||
assert count == 0 # rolled back
|
||||
# #endregion test_add_logs_db_error_rollback
|
||||
# #endregion Test.LogPersistence.TestAddLogsDbErrorRollback
|
||||
|
||||
# #region test_get_logs_with_metadata_json [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestGetLogsWithMetadataJson [C:2] [TYPE Function]
|
||||
# @PURPOSE: get_logs parses metadata_json field correctly.
|
||||
def test_get_logs_with_metadata_json(self):
|
||||
entry = LogEntry(
|
||||
@@ -379,9 +379,9 @@ class TestLogPersistence:
|
||||
logs = self.service.get_logs("test-task-1", LogFilter())
|
||||
assert len(logs) == 1
|
||||
assert logs[0].metadata == {"dashboard_id": "dash-1", "progress": 50}
|
||||
# #endregion test_get_logs_with_metadata_json
|
||||
# #endregion Test.LogPersistence.TestGetLogsWithMetadataJson
|
||||
|
||||
# #region test_get_logs_with_corrupt_metadata_json [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestGetLogsWithCorruptMetadataJson [C:2] [TYPE Function]
|
||||
# @PURPOSE: get_logs handles corrupt metadata_json gracefully.
|
||||
def test_get_logs_with_corrupt_metadata_json(self):
|
||||
# Manually insert a log with corrupt metadata_json
|
||||
@@ -403,9 +403,9 @@ class TestLogPersistence:
|
||||
logs = self.service.get_logs("test-task-1", LogFilter())
|
||||
assert len(logs) == 1
|
||||
assert logs[0].metadata is None # gracefully handled
|
||||
# #endregion test_get_logs_with_corrupt_metadata_json
|
||||
# #endregion Test.LogPersistence.TestGetLogsWithCorruptMetadataJson
|
||||
|
||||
# #region test_delete_logs_for_task_db_error [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestDeleteLogsForTaskDbError [C:2] [TYPE Function]
|
||||
# @PURPOSE: delete_logs_for_task handles database error gracefully.
|
||||
def test_delete_logs_for_task_db_error(self):
|
||||
entry = LogEntry(timestamp=datetime.now(UTC), level="INFO", source="test", message="test")
|
||||
@@ -425,9 +425,9 @@ class TestLogPersistence:
|
||||
count = session.query(TaskLogRecord).filter_by(task_id="test-task-1").count()
|
||||
session.close()
|
||||
assert count == 1
|
||||
# #endregion test_delete_logs_for_task_db_error
|
||||
# #endregion Test.LogPersistence.TestDeleteLogsForTaskDbError
|
||||
|
||||
# #region test_delete_logs_for_tasks_db_error [C:2] [TYPE Function]
|
||||
# #region Test.LogPersistence.TestDeleteLogsForTasksDbError [C:2] [TYPE Function]
|
||||
# @PURPOSE: delete_logs_for_tasks handles database error gracefully.
|
||||
def test_delete_logs_for_tasks_db_error(self):
|
||||
for tid in ["multi-1", "multi-2"]:
|
||||
@@ -449,7 +449,7 @@ class TestLogPersistence:
|
||||
# All logs that were associated with these task_ids should still exist
|
||||
multi_ids = [r.task_id for r in remaining if r.task_id in ("multi-1", "multi-2")]
|
||||
assert len(multi_ids) == 2
|
||||
# #endregion test_delete_logs_for_tasks_db_error
|
||||
# #endregion Test.LogPersistence.TestDeleteLogsForTasksDbError
|
||||
|
||||
# #endregion TestLogPersistence
|
||||
# #endregion test_log_persistence
|
||||
# #endregion Test.LogPersistence.TestLogPersistenceClass
|
||||
# #endregion Test.LogPersistence.Test.Log.Persistence
|
||||
|
||||
Reference in New Issue
Block a user