TT-006: stabilize architecture and add quality gates
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
"""Smoke tests for Request Module."""
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# Compute absolute paths
|
||||
_MODULE_ROOT = Path(__file__).parent.parent.parent.resolve()
|
||||
_PLATFORM_BACKEND = _MODULE_ROOT.parent.parent / "platform" / "backend"
|
||||
|
||||
# Add platform SDK to path so module.py can import BaseModule
|
||||
if str(_PLATFORM_BACKEND) not in sys.path:
|
||||
sys.path.insert(0, str(_PLATFORM_BACKEND))
|
||||
|
||||
# Add module root to path
|
||||
if str(_MODULE_ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(_MODULE_ROOT))
|
||||
|
||||
|
||||
def test_module_import():
|
||||
"""Test that module.py can be imported."""
|
||||
from module import RequestModule
|
||||
assert RequestModule is not None
|
||||
|
||||
|
||||
def test_module_metadata():
|
||||
"""Test module metadata."""
|
||||
from module import RequestModule
|
||||
mod = RequestModule()
|
||||
assert mod.id == "request"
|
||||
assert mod.name == "Request Management"
|
||||
assert mod.version == "1.0.0"
|
||||
|
||||
|
||||
def test_module_permissions():
|
||||
"""Test module permissions."""
|
||||
from module import RequestModule
|
||||
mod = RequestModule()
|
||||
perms = mod.permissions()
|
||||
assert "request.read" in perms
|
||||
assert "request.write" in perms
|
||||
assert "request.delete" in perms
|
||||
|
||||
|
||||
def test_module_frontend_info():
|
||||
"""Test module frontend info."""
|
||||
from module import RequestModule
|
||||
mod = RequestModule()
|
||||
assert mod.frontend.dev_url == "http://localhost:5174"
|
||||
assert mod.frontend.prod_path == "/modules/request"
|
||||
|
||||
|
||||
def test_module_routers():
|
||||
"""Test that module can load routers."""
|
||||
from module import RequestModule
|
||||
mod = RequestModule()
|
||||
routers = mod.routers()
|
||||
assert len(routers) >= 1
|
||||
main_router = routers[0]
|
||||
assert main_router.prefix == "/api/v1/request"
|
||||
|
||||
|
||||
def test_module_static_path():
|
||||
"""Test static path method."""
|
||||
from module import RequestModule
|
||||
mod = RequestModule()
|
||||
static_path = mod.static_path()
|
||||
assert static_path is not None
|
||||
assert static_path.exists()
|
||||
|
||||
|
||||
def test_manifest_json():
|
||||
"""Test manifest.json exists and has required fields."""
|
||||
import json
|
||||
manifest_path = _MODULE_ROOT / "manifest.json"
|
||||
assert manifest_path.exists()
|
||||
with open(manifest_path, encoding="utf-8-sig") as f:
|
||||
manifest = json.load(f)
|
||||
assert "id" in manifest
|
||||
assert "name" in manifest
|
||||
assert "version" in manifest
|
||||
assert manifest["id"] == "request"
|
||||
|
||||
|
||||
def test_request_app_importable():
|
||||
"""Test that request_app package is importable."""
|
||||
from request_app.main import app
|
||||
assert app is not None
|
||||
|
||||
|
||||
def test_request_app_health_route():
|
||||
"""Test that health route exists."""
|
||||
from request_app.api.v1.routes.health import router
|
||||
routes = [r.path for r in router.routes]
|
||||
assert "/health" in routes
|
||||
assert "/module/info" in routes
|
||||
|
||||
|
||||
def test_request_app_has_routes():
|
||||
"""Test that request_app has expected route files."""
|
||||
routes_dir = _MODULE_ROOT / "request_app" / "api" / "v1" / "routes"
|
||||
assert routes_dir.exists()
|
||||
expected_files = ["health.py", "auth.py", "users.py", "tickets.py", "reference.py"]
|
||||
for f in expected_files:
|
||||
assert (routes_dir / f).exists(), f"Missing route file: {f}"
|
||||
Reference in New Issue
Block a user