fix: resolve stale backend test imports and schema drift

- Delete 4 obsolete unit tests tied to removed git mount/clone models
- Update imports and assertions across unit/integration/service tests
- Fix Settings defaults (postgres host, JWT props, cookie_samesite)
- Add skip guards for PostgreSQL-dependent integration tests
- Fix GitService env assertions and HealthMonitor state-change tests
- Repair docker/container inspect assertions in test_docker_service
- Fix ToolTypeCreate default_port validator ordering bug
- Fix check_port_exposed substring false-positive for port 0
- Update test_tool_types_api_extended to use interface_type field

Quality gates: pytest 311 passed, 34 skipped; npm typecheck/lint/test 87 passed
This commit is contained in:
Developer
2026-06-12 20:23:17 +00:00
parent 79be4eb525
commit 81b9a66ef5
35 changed files with 268 additions and 625 deletions
@@ -10,8 +10,31 @@ from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker
from src.auth.session import create_session_cookie
from src.config import Settings, build_database_url
from src.models import Base
from src.models.project import Project
from src.models.user import User
from src.models.project.project import Project
from src.models.user.user import User
def _postgres_available() -> bool:
"""Check whether a PostgreSQL server is reachable for integration tests."""
import asyncpg
async def _check() -> bool:
try:
conn = await asyncpg.connect(
host="localhost", port=5432, user="headquarter", password="headquarter", database="headquarter"
)
await conn.close()
return True
except Exception:
return False
return asyncio.run(_check())
pytestmark = pytest.mark.skipif(
not _postgres_available(),
reason="PostgreSQL not available on localhost:5432",
)
def _prepare_test_db() -> None:
@@ -36,8 +59,8 @@ def _prepare_test_db() -> None:
def _load_app():
import importlib
import src.database as database_module
import src.api.auth as auth_module
import src.api.projects as projects_module
import src.api.user.auth as auth_module
import src.api.project.projects as projects_module
import src.main as main_module
# Dispose old engine connections before reload to prevent pool exhaustion
@@ -56,10 +79,7 @@ def _mint_token(user_id: str) -> str:
settings = Settings()
return create_session_cookie(
settings=settings,
subject=user_id,
email="test@headquarter.local",
name="Test User",
expires_at=datetime.now(UTC) + timedelta(minutes=15),
user_id=user_id,
)