"""Tests for catalog domain models.""" from bridge.catalog.models import ( ActorClass, Catalog, CatalogBridge, CatalogDomain, CatalogTarget, ) class TestCatalogDomain: def test_required_fields(self): d = CatalogDomain(id="coulombcore", name="CoulombCore Infra") assert d.id == "coulombcore" assert d.name == "CoulombCore Infra" def test_optional_fields_default(self): d = CatalogDomain(id="x", name="X") assert d.description == "" assert d.environment == "" class TestCatalogTarget: def test_required_fields(self): t = CatalogTarget(id="state-hub", domain="coulombcore", kind="service") assert t.id == "state-hub" assert t.domain == "coulombcore" assert t.kind == "service" def test_reachable_via_defaults_empty(self): t = CatalogTarget(id="t", domain="d", kind="service") assert t.reachable_via == [] def test_reachable_via(self): t = CatalogTarget(id="t", domain="d", kind="service", reachable_via=["b1", "b2"]) assert t.reachable_via == ["b1", "b2"] class TestCatalogBridge: def test_required_fields(self): b = CatalogBridge( id="state-hub-coulombcore", domain="coulombcore", target="state-hub", host="coulombcore.local", remote_port=18000, local_port=8000, ssh_user="ubuntu", ssh_key="~/.ssh/id_ops", actor="agent.claude-coulombcore", ) assert b.id == "state-hub-coulombcore" assert b.domain == "coulombcore" assert b.host == "coulombcore.local" def test_optional_fields_default(self): b = CatalogBridge( id="b", domain="d", target="t", host="h", remote_port=1, local_port=2, ssh_user="u", ssh_key="k", actor="a", ) assert b.description == "" assert b.access_method == "ssh-reverse" assert b.health_check is None assert b.reconnect is None def test_to_tunnel_config(self): from bridge.models import TunnelConfig b = CatalogBridge( id="state-hub-coulombcore", domain="coulombcore", target="state-hub", host="coulombcore.local", remote_port=18000, local_port=8000, ssh_user="ubuntu", ssh_key="~/.ssh/id_ops", actor="agent.claude-coulombcore", ) tc = b.to_tunnel_config() assert isinstance(tc, TunnelConfig) assert tc.name == "state-hub-coulombcore" assert tc.host == "coulombcore.local" assert tc.remote_port == 18000 class TestActorClass: def test_fields(self): a = ActorClass(id="agent.claude", actor_class="automation", description="Claude agent") assert a.id == "agent.claude" assert a.actor_class == "automation" def test_optional_description(self): a = ActorClass(id="x", actor_class="human") assert a.description == "" class TestCatalog: def test_empty_catalog(self): c = Catalog() assert c.domains == {} assert c.targets == {} assert c.bridges == {} assert c.actors == {} def test_add_entries(self): c = Catalog() c.domains["d"] = CatalogDomain(id="d", name="D") assert "d" in c.domains