test: integration tests for Flask web app routes
This commit is contained in:
1 parent
40e2dbe453
commit
05bdac5515
1 file changed
+57
@@ -0,0 +1,57 @@
|
|||||||
|
"""Integration tests for Flask web app."""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from app import app
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def client():
|
||||||
|
app.config["TESTING"] = True
|
||||||
|
with app.test_client() as client:
|
||||||
|
yield client
|
||||||
|
|
||||||
|
|
||||||
|
def test_index_page(client):
|
||||||
|
"""GET / returns 200."""
|
||||||
|
resp = client.get("/")
|
||||||
|
assert resp.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
def test_jobs_page(client):
|
||||||
|
"""GET /jobs returns 200."""
|
||||||
|
resp = client.get("/jobs")
|
||||||
|
assert resp.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
def test_api_models(client):
|
||||||
|
"""GET /api/models returns JSON list."""
|
||||||
|
resp = client.get("/api/models")
|
||||||
|
assert resp.status_code == 200
|
||||||
|
data = resp.get_json()
|
||||||
|
assert isinstance(data, list)
|
||||||
|
|
||||||
|
|
||||||
|
def test_api_jobs(client):
|
||||||
|
"""GET /api/jobs returns JSON list."""
|
||||||
|
resp = client.get("/api/jobs")
|
||||||
|
assert resp.status_code == 200
|
||||||
|
data = resp.get_json()
|
||||||
|
assert isinstance(data, list)
|
||||||
|
|
||||||
|
|
||||||
|
def test_upload_no_video(client):
|
||||||
|
"""POST /upload without video returns 400."""
|
||||||
|
resp = client.post("/upload")
|
||||||
|
assert resp.status_code == 400
|
||||||
|
|
||||||
|
|
||||||
|
def test_status_nonexistent(client):
|
||||||
|
"""GET /status/nonexistent returns 404."""
|
||||||
|
resp = client.get("/status/nonexistent")
|
||||||
|
assert resp.status_code == 404
|
||||||
|
|
||||||
|
|
||||||
|
def test_api_job_detail_nonexistent(client):
|
||||||
|
"""GET /api/jobs/nonexistent returns 404."""
|
||||||
|
resp = client.get("/api/jobs/nonexistent")
|
||||||
|
assert resp.status_code == 404
|
||||||
Reference in new issue
Block a user