diff --git a/tests/test_http.py b/tests/test_http.py index f2b9a084..aa398441 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -17,7 +17,9 @@ TEST_APP_CODE = """ api.export({ async setup(){ - await api.register_service( + }, + async register_services(){ + const service_info1 = await api.register_service( { "id": "test_service", "name": "test_service", @@ -31,7 +33,8 @@ } } ) - await api.register_service( + console.log(`registered test_service: ${service_info1.id}`) + const service_info2 = await api.register_service( { "id": "test_service_protected", "name": "test_service_protected", @@ -45,6 +48,8 @@ } } ) + console.log(`registered test_service: ${service_info2.id}`) + return [service_info1, service_info2] } }) """ @@ -74,6 +79,7 @@ async def test_services(minio_server, fastapi_server, test_user_token): async with httpx.AsyncClient(timeout=60.0) as client: data = await client.get(f"{SERVER_URL}/services/openapi.json") data = data.json() + assert data.get("detail") != "Not Found" assert data["info"]["title"] == "Hypha Services" paths = data["paths"] assert "/call" in paths @@ -105,12 +111,14 @@ async def test_services(minio_server, fastapi_server, test_user_token): assert data.status_code == 200 assert data.json() == "123" - data = await client.get(f"{SERVER_URL}/services?workspace={workspace}") + data = await client.get(f"{SERVER_URL}/services/list?workspace={workspace}") print(data.json()) # [{'config': {'visibility': 'public', 'require_context': False, 'workspace': 'VRRVEdTF9of2y4cLmepzBw', 'flags': []}, 'id': '5XCPAyZrW72oBzywEk2oxP:test_service', 'name': 'test_service', 'type': 'test_service', 'description': '', 'docs': {}}] assert data.status_code == 200 assert data.json()[0]["name"] == "test_service" + await api.disconnect() + # pylint: disable=too-many-statements async def test_http_proxy(minio_server, fastapi_server, test_user_token): @@ -135,15 +143,15 @@ async def test_http_proxy(minio_server, fastapi_server, test_user_token): wait_for_service=None, ) plugin = await api.get_plugin(config.id) - assert "setup" in plugin - await plugin.setup() + assert "setup" in plugin and "register_services" in plugin + svc1, svc2 = await plugin.register_services() service_ws = plugin.config.workspace assert service_ws - service = await api.get_service("test_service") + service = await api.get_service(svc1["id"]) assert await service.echo("233d") == "233d" - service = await api.get_service("test_service_protected") + service = await api.get_service(svc2["id"]) assert await service.echo("22") == "22" response = requests.get(f"{SERVER_URL}/workspaces/list")