CI/CD: Gitea Actions workflow med tests
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
"""Tests for card/series/set endpoints."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
class TestCardsAPI:
|
||||
"""Tests for card browsning (no auth required for browse endpoints)."""
|
||||
|
||||
async def test_series_list(self, client, admin_token):
|
||||
client.cookies.set("token", admin_token)
|
||||
resp = await client.get("/series")
|
||||
assert resp.status_code == 200
|
||||
assert "text/html" in resp.headers["content-type"]
|
||||
|
||||
async def test_sets_list(self, client, admin_token):
|
||||
client.cookies.set("token", admin_token)
|
||||
resp = await client.get("/sets")
|
||||
assert resp.status_code == 200
|
||||
|
||||
async def test_search_page(self, client, admin_token):
|
||||
client.cookies.set("token", admin_token)
|
||||
resp = await client.get("/search")
|
||||
assert resp.status_code == 200
|
||||
|
||||
# ── JSON API ──────────────────────────────────────────────
|
||||
|
||||
async def test_api_series(self, client):
|
||||
resp = await client.get("/api/series")
|
||||
assert resp.status_code == 200
|
||||
assert isinstance(resp.json(), list)
|
||||
|
||||
async def test_api_sets(self, client):
|
||||
resp = await client.get("/api/sets")
|
||||
assert resp.status_code == 200
|
||||
assert isinstance(resp.json(), list)
|
||||
|
||||
async def test_api_series_sets_not_found(self, client):
|
||||
resp = await client.get("/api/series/FinnesIkke/sets")
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert "error" in data
|
||||
|
||||
async def test_api_sets_cards_not_found(self, client):
|
||||
resp = await client.get("/api/sets/XXX/cards")
|
||||
assert resp.status_code == 200
|
||||
assert resp.json() == []
|
||||
|
||||
async def test_search_empty(self, client):
|
||||
resp = await client.get("/api/search")
|
||||
assert resp.status_code == 200
|
||||
assert resp.json() == []
|
||||
|
||||
async def test_search_no_match(self, client):
|
||||
resp = await client.get("/api/search?q=zzz_nonexistent_xyz")
|
||||
assert resp.status_code == 200
|
||||
assert resp.json() == []
|
||||
|
||||
# ── 404 tests ─────────────────────────────────────────────
|
||||
|
||||
async def test_serie_detail_404(self, client, admin_token):
|
||||
client.cookies.set("token", admin_token)
|
||||
resp = await client.get("/series/FinnesIkke")
|
||||
assert resp.status_code == 404
|
||||
|
||||
async def test_set_detail_404(self, client, admin_token):
|
||||
client.cookies.set("token", admin_token)
|
||||
resp = await client.get("/sets/ZZZ")
|
||||
assert resp.status_code == 404
|
||||
|
||||
async def test_card_detail_404(self, client, admin_token):
|
||||
client.cookies.set("token", admin_token)
|
||||
resp = await client.get("/card/ZZZ/999")
|
||||
assert resp.status_code == 404
|
||||
Reference in New Issue
Block a user