import pytest from fastapi.testclient import TestClient from argos.server import app, models @pytest.fixture() def test_db(): models.Base.metadata.create_all(bind=app.engine) yield models.Base.metadata.drop_all(bind=app.engine) def test_read_tasks_requires_auth(): with TestClient(app) as client: response = client.get("/tasks") assert response.status_code == 403 def test_read_tasks_returns_tasks(): with TestClient(app) as client: token = app.state.config.service.secrets[0] client.headers = {"Authorization": f"Bearer {token}"} response = client.get("/tasks") assert response.status_code == 200 # We should have only two tasks assert len(response.json()) == 2