first commit
This commit is contained in:
commit
34ea15a54d
246 changed files with 18660 additions and 0 deletions
64
backend/tests/test_catalog_api.py
Normal file
64
backend/tests/test_catalog_api.py
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_list_events_published() -> None:
|
||||
response = client.get("/api/events")
|
||||
assert response.status_code == 200
|
||||
body = response.json()
|
||||
assert isinstance(body, list)
|
||||
if body:
|
||||
assert "slug" in body[0]
|
||||
assert "venue" in body[0]
|
||||
assert body[0]["status"] == "published"
|
||||
|
||||
|
||||
def test_list_events_filter_category() -> None:
|
||||
response = client.get("/api/events", params={"category": "garba", "upcoming": "false"})
|
||||
assert response.status_code == 200
|
||||
for item in response.json():
|
||||
assert item["category"] == "garba"
|
||||
|
||||
|
||||
def test_get_event_by_slug() -> None:
|
||||
listing = client.get("/api/events", params={"upcoming": "false"})
|
||||
assert listing.status_code == 200
|
||||
if not listing.json():
|
||||
return
|
||||
slug = listing.json()[0]["slug"]
|
||||
detail = client.get(f"/api/events/{slug}")
|
||||
assert detail.status_code == 200
|
||||
data = detail.json()
|
||||
assert data["slug"] == slug
|
||||
assert "ticket_types" in data
|
||||
assert "media" in data
|
||||
|
||||
|
||||
def test_get_event_not_found() -> None:
|
||||
response = client.get("/api/events/does-not-exist-slug")
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
def test_list_venues() -> None:
|
||||
response = client.get("/api/venues")
|
||||
assert response.status_code == 200
|
||||
assert isinstance(response.json(), list)
|
||||
|
||||
|
||||
def test_get_venue_by_id() -> None:
|
||||
listing = client.get("/api/venues")
|
||||
assert listing.status_code == 200
|
||||
if not listing.json():
|
||||
return
|
||||
venue_id = listing.json()[0]["id"]
|
||||
response = client.get(f"/api/venues/{venue_id}")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["id"] == venue_id
|
||||
|
||||
|
||||
def test_get_venue_not_found() -> None:
|
||||
response = client.get("/api/venues/999999")
|
||||
assert response.status_code == 404
|
||||
Loading…
Add table
Add a link
Reference in a new issue