"""Tests for governed connector module.""" import pytest @pytest.mark.asyncio async def test_list_connectors(client): resp = await client.get("/connectors/") assert resp.status_code == 200 catalogue = resp.json() ids = [c["connector_id"] for c in catalogue] assert "echo" in ids @pytest.mark.asyncio async def test_get_descriptor(client): resp = await client.get("/connectors/echo/") assert resp.status_code == 200 desc = resp.json() assert "corpus_entry_cid" in desc assert desc["corpus_entry_cid"].startswith("sha256:") @pytest.mark.asyncio async def test_invoke_echo(client): resp = await client.post( "/connectors/echo/invoke/", json={"operation": "echo", "parameters": {"msg": "hello"}}, ) assert resp.status_code == 200 body = resp.json() assert body["success"] is True assert body["data"]["msg"] == "hello" assert body["connector_id"] == "echo" assert body["operation"] == "echo" @pytest.mark.asyncio async def test_invoke_unknown_404(client): resp = await client.post( "/connectors/nonexistent/invoke/", json={"operation": "test", "parameters": {}}, ) assert resp.status_code == 404 @pytest.mark.asyncio async def test_health_check(client): resp = await client.get("/connectors/echo/health/") assert resp.status_code == 200 body = resp.json() assert body["healthy"] is True assert body["connector_id"] == "echo"