-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_app.py
More file actions
36 lines (24 loc) · 730 Bytes
/
test_app.py
File metadata and controls
36 lines (24 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pytest
from fastapi.testclient import TestClient
from src.settings.database import engine
from app import app
@pytest.fixture
def client():
with TestClient(app) as client:
yield client
@pytest.fixture
def mock_db_session():
session = engine.connect()
yield session
session.close()
def test_db_session_middleware(mock_db_session):
# Test the database session middleware
assert mock_db_session is not None
def test_task_router(client):
# Test the task router
response = client.get("/tasks/")
assert response.status_code == 200
def test_project_router(client):
# Test the project router
response = client.get("/projects/")
assert response.status_code == 200