CI/CD: Gitea Actions workflow med tests
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""Tests for admin endpoints."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
class TestAdmin:
|
||||
"""Admin routes require admin role."""
|
||||
|
||||
async def test_dashboard_requires_admin(self, client, user_token):
|
||||
client.cookies.set("token", user_token)
|
||||
resp = await client.get("/admin/", follow_redirects=False)
|
||||
assert resp.status_code == 401
|
||||
|
||||
async def test_dashboard_as_admin(self, client, admin_token):
|
||||
client.cookies.set("token", admin_token)
|
||||
resp = await client.get("/admin/")
|
||||
assert resp.status_code == 200
|
||||
assert "text/html" in resp.headers["content-type"]
|
||||
|
||||
async def test_series_admin_requires_admin(self, client, user_token):
|
||||
client.cookies.set("token", user_token)
|
||||
resp = await client.get("/admin/series", follow_redirects=False)
|
||||
assert resp.status_code == 401
|
||||
|
||||
async def test_series_admin_as_admin(self, client, admin_token):
|
||||
client.cookies.set("token", admin_token)
|
||||
resp = await client.get("/admin/series")
|
||||
assert resp.status_code == 200
|
||||
|
||||
async def test_sets_admin_as_admin(self, client, admin_token):
|
||||
client.cookies.set("token", admin_token)
|
||||
resp = await client.get("/admin/sets")
|
||||
assert resp.status_code == 200
|
||||
|
||||
async def test_cards_admin_as_admin(self, client, admin_token):
|
||||
client.cookies.set("token", admin_token)
|
||||
resp = await client.get("/admin/cards")
|
||||
assert resp.status_code == 200
|
||||
Reference in New Issue
Block a user