Skip to content

Commit 489bbd2

Browse files
authored
chore: remove llm gateway tests (#42618)
1 parent b06b026 commit 489bbd2

File tree

3 files changed

+121
-121
lines changed

3 files changed

+121
-121
lines changed

products/llm-gateway/README.md

Whitespace-only changes.
Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,70 @@
1-
from collections.abc import AsyncGenerator, Generator
2-
from unittest.mock import AsyncMock, MagicMock
3-
4-
import pytest
5-
from fastapi import FastAPI
6-
from fastapi.testclient import TestClient
7-
from httpx import ASGITransport, AsyncClient
8-
9-
from llm_gateway.auth.models import AuthenticatedUser
10-
from llm_gateway.main import create_app
11-
12-
13-
@pytest.fixture
14-
def mock_db_pool() -> MagicMock:
15-
pool = MagicMock()
16-
pool.acquire = MagicMock()
17-
conn = AsyncMock()
18-
conn.fetchrow = AsyncMock(return_value=None)
19-
conn.fetchval = AsyncMock(return_value=1)
20-
pool.acquire.return_value.__aenter__ = AsyncMock(return_value=conn)
21-
pool.acquire.return_value.__aexit__ = AsyncMock(return_value=None)
22-
return pool
23-
24-
25-
@pytest.fixture
26-
def authenticated_user() -> AuthenticatedUser:
27-
return AuthenticatedUser(
28-
user_id=1,
29-
team_id=1,
30-
auth_method="personal_api_key",
31-
scopes=["task:write"],
32-
)
33-
34-
35-
@pytest.fixture
36-
def app(mock_db_pool: MagicMock) -> Generator[FastAPI, None, None]:
37-
application = create_app()
38-
application.state.db_pool = mock_db_pool
39-
yield application
40-
41-
42-
@pytest.fixture
43-
def client(app: MagicMock) -> TestClient:
44-
return TestClient(app)
45-
46-
47-
@pytest.fixture
48-
async def async_client(app: MagicMock) -> AsyncGenerator[AsyncClient, None]:
49-
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac:
50-
yield ac
51-
52-
53-
@pytest.fixture
54-
def authenticated_client(mock_db_pool: MagicMock) -> TestClient:
55-
app = create_app()
56-
app.state.db_pool = mock_db_pool
57-
58-
conn = AsyncMock()
59-
conn.fetchrow = AsyncMock(
60-
return_value={
61-
"id": "key_id",
62-
"user_id": 1,
63-
"scopes": ["task:write"],
64-
"current_team_id": 1,
65-
}
66-
)
67-
mock_db_pool.acquire.return_value.__aenter__ = AsyncMock(return_value=conn)
68-
mock_db_pool.acquire.return_value.__aexit__ = AsyncMock(return_value=None)
69-
70-
return TestClient(app)
1+
# from collections.abc import AsyncGenerator, Generator
2+
# from unittest.mock import AsyncMock, MagicMock
3+
4+
# import pytest
5+
# from fastapi import FastAPI
6+
# from fastapi.testclient import TestClient
7+
# from httpx import ASGITransport, AsyncClient
8+
9+
# from llm_gateway.auth.models import AuthenticatedUser
10+
# from llm_gateway.main import create_app
11+
12+
13+
# @pytest.fixture
14+
# def mock_db_pool() -> MagicMock:
15+
# pool = MagicMock()
16+
# pool.acquire = MagicMock()
17+
# conn = AsyncMock()
18+
# conn.fetchrow = AsyncMock(return_value=None)
19+
# conn.fetchval = AsyncMock(return_value=1)
20+
# pool.acquire.return_value.__aenter__ = AsyncMock(return_value=conn)
21+
# pool.acquire.return_value.__aexit__ = AsyncMock(return_value=None)
22+
# return pool
23+
24+
25+
# @pytest.fixture
26+
# def authenticated_user() -> AuthenticatedUser:
27+
# return AuthenticatedUser(
28+
# user_id=1,
29+
# team_id=1,
30+
# auth_method="personal_api_key",
31+
# scopes=["task:write"],
32+
# )
33+
34+
35+
# @pytest.fixture
36+
# def app(mock_db_pool: MagicMock) -> Generator[FastAPI, None, None]:
37+
# application = create_app()
38+
# application.state.db_pool = mock_db_pool
39+
# yield application
40+
41+
42+
# @pytest.fixture
43+
# def client(app: MagicMock) -> TestClient:
44+
# return TestClient(app)
45+
46+
47+
# @pytest.fixture
48+
# async def async_client(app: MagicMock) -> AsyncGenerator[AsyncClient, None]:
49+
# async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac:
50+
# yield ac
51+
52+
53+
# @pytest.fixture
54+
# def authenticated_client(mock_db_pool: MagicMock) -> TestClient:
55+
# app = create_app()
56+
# app.state.db_pool = mock_db_pool
57+
58+
# conn = AsyncMock()
59+
# conn.fetchrow = AsyncMock(
60+
# return_value={
61+
# "id": "key_id",
62+
# "user_id": 1,
63+
# "scopes": ["task:write"],
64+
# "current_team_id": 1,
65+
# }
66+
# )
67+
# mock_db_pool.acquire.return_value.__aenter__ = AsyncMock(return_value=conn)
68+
# mock_db_pool.acquire.return_value.__aexit__ = AsyncMock(return_value=None)
69+
70+
# return TestClient(app)
Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
from unittest.mock import AsyncMock, MagicMock
2-
3-
import pytest
4-
from fastapi.testclient import TestClient
5-
6-
from llm_gateway.main import create_app
7-
8-
9-
class TestHealthEndpoints:
10-
@pytest.fixture
11-
def client_with_healthy_db(self, mock_db_pool: MagicMock) -> TestClient:
12-
app = create_app()
13-
app.state.db_pool = mock_db_pool
14-
return TestClient(app)
15-
16-
@pytest.fixture
17-
def client_with_unhealthy_db(self) -> TestClient:
18-
app = create_app()
19-
pool = MagicMock()
20-
pool.acquire.return_value.__aenter__ = AsyncMock(side_effect=Exception("Connection failed"))
21-
pool.acquire.return_value.__aexit__ = AsyncMock(return_value=None)
22-
app.state.db_pool = pool
23-
return TestClient(app)
24-
25-
@pytest.mark.parametrize(
26-
"endpoint,expected_status,expected_body",
27-
[
28-
pytest.param("/", 200, {"service": "llm-gateway", "status": "running"}, id="root"),
29-
pytest.param("/_liveness", 200, {"status": "alive"}, id="liveness"),
30-
pytest.param("/_readiness", 200, {"status": "ready"}, id="readiness"),
31-
],
32-
)
33-
def test_healthy_endpoints(
34-
self,
35-
client_with_healthy_db: TestClient,
36-
endpoint: str,
37-
expected_status: int,
38-
expected_body: dict,
39-
) -> None:
40-
response = client_with_healthy_db.get(endpoint)
41-
assert response.status_code == expected_status
42-
assert response.json() == expected_body
43-
44-
def test_readiness_fails_when_db_unavailable(self, client_with_unhealthy_db: TestClient) -> None:
45-
response = client_with_unhealthy_db.get("/_readiness")
46-
assert response.status_code == 503
47-
assert response.json()["detail"] == "Database not ready"
48-
49-
def test_liveness_succeeds_when_db_unavailable(self, client_with_unhealthy_db: TestClient) -> None:
50-
response = client_with_unhealthy_db.get("/_liveness")
51-
assert response.status_code == 200
1+
# from unittest.mock import AsyncMock, MagicMock
2+
3+
# import pytest
4+
# from fastapi.testclient import TestClient
5+
6+
# from llm_gateway.main import create_app
7+
8+
9+
# class TestHealthEndpoints:
10+
# @pytest.fixture
11+
# def client_with_healthy_db(self, mock_db_pool: MagicMock) -> TestClient:
12+
# app = create_app()
13+
# app.state.db_pool = mock_db_pool
14+
# return TestClient(app)
15+
16+
# @pytest.fixture
17+
# def client_with_unhealthy_db(self) -> TestClient:
18+
# app = create_app()
19+
# pool = MagicMock()
20+
# pool.acquire.return_value.__aenter__ = AsyncMock(side_effect=Exception("Connection failed"))
21+
# pool.acquire.return_value.__aexit__ = AsyncMock(return_value=None)
22+
# app.state.db_pool = pool
23+
# return TestClient(app)
24+
25+
# @pytest.mark.parametrize(
26+
# "endpoint,expected_status,expected_body",
27+
# [
28+
# pytest.param("/", 200, {"service": "llm-gateway", "status": "running"}, id="root"),
29+
# pytest.param("/_liveness", 200, {"status": "alive"}, id="liveness"),
30+
# pytest.param("/_readiness", 200, {"status": "ready"}, id="readiness"),
31+
# ],
32+
# )
33+
# def test_healthy_endpoints(
34+
# self,
35+
# client_with_healthy_db: TestClient,
36+
# endpoint: str,
37+
# expected_status: int,
38+
# expected_body: dict,
39+
# ) -> None:
40+
# response = client_with_healthy_db.get(endpoint)
41+
# assert response.status_code == expected_status
42+
# assert response.json() == expected_body
43+
44+
# def test_readiness_fails_when_db_unavailable(self, client_with_unhealthy_db: TestClient) -> None:
45+
# response = client_with_unhealthy_db.get("/_readiness")
46+
# assert response.status_code == 503
47+
# assert response.json()["detail"] == "Database not ready"
48+
49+
# def test_liveness_succeeds_when_db_unavailable(self, client_with_unhealthy_db: TestClient) -> None:
50+
# response = client_with_unhealthy_db.get("/_liveness")
51+
# assert response.status_code == 200

0 commit comments

Comments
 (0)