55 lines
2.2 KiB
Python
55 lines
2.2 KiB
Python
|
|
import sys
|
|
import os
|
|
import asyncio
|
|
from unittest.mock import MagicMock
|
|
|
|
# Add project root to path
|
|
sys.path.append(os.getcwd())
|
|
|
|
# Mock settings to avoid environment variable issues
|
|
sys.modules["app.core.config"] = MagicMock()
|
|
sys.modules["app.core.config"].settings.DATABASE_URL = "postgresql+asyncpg://user:pass@localhost/db"
|
|
|
|
async def test_import():
|
|
print("Attempting to import shared.database.base...")
|
|
try:
|
|
from shared.database.base import create_database_manager
|
|
print(f"Successfully imported create_database_manager: {create_database_manager}")
|
|
except Exception as e:
|
|
print(f"Failed to import create_database_manager: {e}")
|
|
return
|
|
|
|
print("Attempting to import services.tenant.app.api.tenant_locations...")
|
|
try:
|
|
# We need to mock dependencies that might fail
|
|
sys.modules["app.schemas.tenant_locations"] = MagicMock()
|
|
sys.modules["app.repositories.tenant_location_repository"] = MagicMock()
|
|
sys.modules["shared.auth.decorators"] = MagicMock()
|
|
sys.modules["shared.auth.access_control"] = MagicMock()
|
|
sys.modules["shared.monitoring.metrics"] = MagicMock()
|
|
sys.modules["shared.routing.route_builder"] = MagicMock()
|
|
|
|
# Mock RouteBuilder to return a mock object with build_base_route
|
|
route_builder_mock = MagicMock()
|
|
route_builder_mock.build_base_route.return_value = "/mock/route"
|
|
sys.modules["shared.routing.route_builder"].RouteBuilder = MagicMock(return_value=route_builder_mock)
|
|
|
|
# Now import the module
|
|
from services.tenant.app.api import tenant_locations
|
|
print("Successfully imported services.tenant.app.api.tenant_locations")
|
|
|
|
# Check if create_database_manager is available in the module's namespace
|
|
if hasattr(tenant_locations, "create_database_manager"):
|
|
print("create_database_manager is present in tenant_locations module")
|
|
else:
|
|
print("create_database_manager is MISSING from tenant_locations module")
|
|
|
|
except Exception as e:
|
|
print(f"Failed to import tenant_locations: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(test_import())
|