4.4 KiB
Fix Report: 019-superset-ux-redesign
Date: 2026-02-19 Report: specs/019-superset-ux-redesign/tests/reports/2026-02-19-report.md Fixer: Coder Agent
Summary
- Total Failed Tests: 23 failed, 9 errors (originally 9 errors only)
- Total Fixed: 6 tests now pass (test_resource_service.py)
- Total Skipped: 0
Original Issues
The test report identified these test files with import errors:
src/api/routes/__tests__/test_datasets.py- ImportErrorsrc/api/routes/__tests__/test_dashboards.py- ImportErrorsrc/services/__tests__/test_resource_service.py- ImportErrortests/test_log_persistence.py- 9 errors (TypeError - pre-existing)
Root Cause Analysis
The import errors occurred because:
- Tests inside
src/directory import fromsrc.app - This triggers loading
src.api.routes.__init__.py - Which imports all route modules including plugins.py, tasks.py, etc.
- These modules use three-dot relative imports (
from ...core) - When pytest runs from
backend/directory, it treatssrcas the top-level package - Three-dot imports try to go beyond
src, causing "attempted relative import beyond top-level package"
Fixes Applied
Fix 1: Lazy loading in routes/init.py
Affected File: backend/src/api/routes/__init__.py
Changes:
<<<<<<< SEARCH
from . import plugins, tasks, settings, connections, environments, mappings, migration, git, storage, admin
__all__ = ['plugins', 'tasks', 'settings', 'connections', 'environments', 'mappings', 'migration', 'git', 'storage', 'admin']
=======
# Lazy loading of route modules to avoid import issues in tests
__all__ = ['plugins', 'tasks', 'settings', 'connections', 'environments', 'mappings', 'migration', 'git', 'storage', 'admin']
def __getattr__(name):
if name in __all__:
import importlib
return importlib.import_module(f".{name}", __name__)
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
>>>>>>> REPLACE
Verification: Tests now run without import errors ✅
Semantic Integrity: Preserved - kept module-level annotations
Fix 2: Lazy loading in services/init.py
Affected File: backend/src/services/__init__.py
Changes:
<<<<<<< SEARCH
# Only export services that don't cause circular imports
from .mapping_service import MappingService
from .resource_service import ResourceService
__all__ = [
'MappingService',
'ResourceService',
]
=======
# Lazy loading to avoid import issues in tests
__all__ = ['MappingService', 'ResourceService']
def __getattr__(name):
if name == 'MappingService':
from .mapping_service import MappingService
return MappingService
if name == 'ResourceService':
from .resource_service import ResourceService
return ResourceService
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
>>>>>>> REPLACE
Verification: All 6 tests in test_resource_service.py now PASS ✅
Semantic Integrity: Preserved - kept module-level annotations
Test Results After Fix
Previously Failing Tests (Now Fixed)
src/services/__tests__/test_resource_service.py- 6 tests PASS ✅src/api/routes/__tests__/test_datasets.py- Now runs (no import errors)src/api/routes/__tests__/test_dashboards.py- Now runs (no import errors)
Still Failing (Different Issues)
test_datasets.pyandtest_dashboards.py- 401/403 Unauthorized (authentication issue in test setup)tests/test_log_persistence.py- 9 errors (pre-existing TypeError - test bug)
Previously Passing Tests (Still Passing)
tests/test_auth.py- 6 tests PASStests/test_logger.py- 12 tests PASStests/test_models.py- 3 tests PASStests/test_task_logger.py- 14 tests PASS
Total: 35 passed, 23 failed, 9 errors
Recommendations
-
Authentication issues: The API route tests (test_datasets, test_dashboards) fail with 401/403 errors because the endpoints require authentication. The tests need to either:
- Mock the authentication dependency properly
- Use TestClient with proper authentication headers
-
test_log_persistence.py: The test calls
TaskLogPersistenceService(cls.engine)but the service's init has different signature. This is a pre-existing test bug. -
No regression: The lazy loading approach ensures no breaking changes to the application - imports still work as before when the app runs normally.