66 lines
2.1 KiB
Python
66 lines
2.1 KiB
Python
from __future__ import annotations
|
|
|
|
import importlib.util
|
|
from dataclasses import dataclass
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
import aios_v2r1
|
|
from aios_v2r1 import cli
|
|
from aios_v2r1.ingress_service import IngressHTTPServer
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def test_canonical_package_has_one_identity_and_no_compatibility_shim() -> None:
|
|
assert aios_v2r1.__name__ == "aios_v2r1"
|
|
assert aios_v2r1.__package__ == "aios_v2r1"
|
|
assert aios_v2r1.__version__ == "2.1.0-rc.1"
|
|
assert importlib.util.find_spec("active_runtime") is None
|
|
assert not (ROOT / "active_runtime").exists()
|
|
|
|
|
|
def test_packaging_metadata_declares_only_the_canonical_app_package() -> None:
|
|
metadata = (ROOT / "active-runtime" / "pyproject.toml").read_text()
|
|
assert 'packages = ["aios_v2r1"]' in metadata
|
|
assert 'package-dir = {"" = "app"}' in metadata
|
|
assert "active_runtime" not in metadata
|
|
assert 'aios-cell = "aios_v2r1.cli:main"' in metadata
|
|
|
|
|
|
def test_registry_path_named_serve_keeps_legacy_status_dispatch(
|
|
monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
|
|
) -> None:
|
|
calls: list[tuple[str, str]] = []
|
|
|
|
@dataclass
|
|
class Result:
|
|
tenant_id: str
|
|
state: str
|
|
|
|
class FakeManager:
|
|
def __init__(self, registry: str) -> None:
|
|
calls.append(("registry", registry))
|
|
|
|
def status(self, tenant_id: str) -> Result:
|
|
calls.append(("status", tenant_id))
|
|
return Result(tenant_id=tenant_id, state="healthy")
|
|
|
|
monkeypatch.setattr(cli, "CellManager", FakeManager)
|
|
monkeypatch.setattr(
|
|
cli,
|
|
"serve",
|
|
lambda host, port: pytest.fail("legacy registry command entered service mode"),
|
|
)
|
|
|
|
assert cli.main(["serve", "status", "tenant-a"]) == 0
|
|
assert calls == [("registry", "serve"), ("status", "tenant-a")]
|
|
assert '"tenant_id": "tenant-a"' in capsys.readouterr().out
|
|
|
|
|
|
def test_packaged_server_waits_for_non_daemon_request_handlers() -> None:
|
|
assert IngressHTTPServer.daemon_threads is False
|
|
assert IngressHTTPServer.block_on_close is True
|