Repo-side rename only (Phases 1-3 of the migration plan); the live box (~/.castle, systemd units, /data/castle, domains) is a separate cutover. - Slug `castle` -> `wildpc`: CLI command, module names (wildpc_core/cli/api), dist names, entry point `wildpc = wildpc_cli.main:main`. - Identifiers: CastleConfig/NATSClient/DirError/MDNS -> Wildpc*. - Env/constants: CASTLE_* -> WILDPC_*; ~/.castle -> ~/.wildpc, castle.yaml -> wildpc.yaml, /data/castle -> /data/wildpc. - Systemd UNIT_PREFIX castle- -> wildpc-; own programs castle-api/gateway/etc. - Display prose "Castle" -> "Wild PC" in docs, agent-guide files, README, frontend. - Package dirs and bootstrap yaml renamed via git mv; lockfiles regenerated; redundant nested uv.lock files dropped (workspace root lock is authoritative). Tests: core 273, cli 47, wildpc-api 120 all pass. Frontend type-checks + builds. Fixed a stale test fixture (secret_env_path kind arg) broken pre-rename.
39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
"""Tests for cascade program deletion via /config/programs/{name}."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
class TestCascadeDelete:
|
|
def test_blocked_without_cascade(self, client: TestClient) -> None:
|
|
"""A program with a referencing deployment refuses a plain delete (409)."""
|
|
# test-tool (program) is referenced by test-tool (a path deployment).
|
|
r = client.delete("/config/programs/test-tool")
|
|
assert r.status_code == 409
|
|
assert "cascade" in r.json()["detail"]
|
|
|
|
def test_cascade_removes_program_and_deployment(
|
|
self, client: TestClient, monkeypatch: pytest.MonkeyPatch
|
|
) -> None:
|
|
"""cascade=true tears down + removes the deployments and the program."""
|
|
# Stub the runtime teardown so the test has no systemctl/deploy side effects.
|
|
import wildpc_core.deploy as dp
|
|
import wildpc_core.lifecycle as lc
|
|
|
|
async def _noop(*_a: object, **_k: object) -> None:
|
|
return None
|
|
|
|
monkeypatch.setattr(lc, "deactivate", _noop)
|
|
monkeypatch.setattr(dp, "deploy", lambda *_a, **_k: None)
|
|
|
|
r = client.delete("/config/programs/test-tool?cascade=true")
|
|
assert r.status_code == 200
|
|
body = r.json()
|
|
assert body["action"] == "deleted"
|
|
assert "test-tool" in body["removed_deployments"]
|
|
|
|
# The program is gone from the catalog.
|
|
assert client.get("/programs/test-tool").status_code == 404
|