Skip to content

Commit

Permalink
Add endpoint tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Georges-Antoine Assi committed Aug 13, 2023
1 parent acaaee6 commit bd186b0
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 3 deletions.
Empty file.
9 changes: 9 additions & 0 deletions backend/endpoints/tests/test_heartbeat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from fastapi.testclient import TestClient

from main import app

def test_heartbeat():
with TestClient(app) as client:
response = client.get("/heartbeat")
assert response.status_code == 200
assert response.json() == {"status": "ok"}
9 changes: 9 additions & 0 deletions backend/endpoints/tests/test_platform.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from fastapi.testclient import TestClient

from main import app

def test_platforms():
with TestClient(app) as client:
response = client.get("/platforms")
assert response.status_code == 200
assert response.json() == {"status": "ok"}
6 changes: 5 additions & 1 deletion backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
from config import DEV_PORT, DEV_HOST, ROMM_AUTH_SECRET_KEY
from endpoints import search, platform, rom, identity, oauth, scan # noqa
from utils.socket import socket_app
from utils.auth import HybridAuthBackend, CustomCSRFMiddleware, create_default_admin_user
from utils.auth import (
HybridAuthBackend,
CustomCSRFMiddleware,
create_default_admin_user,
)

app = FastAPI()

Expand Down
2 changes: 1 addition & 1 deletion backend/utils/tests/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def test_get_current_active_user_from_token_invalid_token():
async def test_get_current_active_user_from_token_invalid_user():
token = create_oauth_token({"sub": "invalid_user"})

with pytest.raises(HTTPException) as e:
with pytest.raises(HTTPException):
await get_current_active_user_from_token(token)


Expand Down
46 changes: 45 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ itsdangerous = "^2.1.2"
stream-zip = "^0.0.67"
starlette-csrf = "^3.0.0"
pytest-asyncio = "^0.21.1"
httpx = "^0.24.1"

[build-system]
requires = ["poetry-core"]
Expand Down

0 comments on commit bd186b0

Please sign in to comment.