58 lines
1.7 KiB
Python
58 lines
1.7 KiB
Python
from fastapi.testclient import TestClient
|
|
|
|
from app.main import app
|
|
|
|
client = TestClient(app)
|
|
|
|
|
|
def test_health():
|
|
response = client.get("/health")
|
|
assert response.status_code == 200
|
|
body = response.json()
|
|
assert body["status"] == "ok"
|
|
|
|
|
|
def test_menu_contains_fish():
|
|
response = client.get("/menu")
|
|
assert response.status_code == 200
|
|
body = response.json()
|
|
mains = [main.lower() for main in body["mains"]]
|
|
assert any("pescado" in main or "pedro" in main for main in mains)
|
|
assert body["menu_price"] == 5.5
|
|
deal = body["university_deal"]
|
|
assert deal["old_price"] == 4.5
|
|
assert deal["current_price"] == 5.5
|
|
|
|
|
|
def test_prices_random_list():
|
|
response = client.get("/prices")
|
|
assert response.status_code == 200
|
|
body = response.json()
|
|
items = body["items"]
|
|
assert isinstance(items, list)
|
|
assert len(items) >= 1
|
|
first = items[0]
|
|
assert "item" in first and "price" in first and "currency" in first
|
|
assert all(item["price"] <= 3 for item in items)
|
|
|
|
|
|
def test_build_history():
|
|
response = client.get("/builds")
|
|
assert response.status_code == 200
|
|
body = response.json()
|
|
builds = body["builds"]
|
|
assert isinstance(builds, list)
|
|
assert len(builds) >= 1
|
|
|
|
first = builds[0]
|
|
assert "number" in first and "status" in first and "branch" in first
|
|
|
|
# Ensure descending order by build number
|
|
numbers = [build["number"] for build in builds]
|
|
assert numbers == sorted(numbers, reverse=True)
|
|
|
|
failed_builds = [build for build in builds if build["status"] == "failed"]
|
|
if failed_builds:
|
|
failed = failed_builds[0]
|
|
assert "failed_stage" in failed and "fun_message" in failed
|