23 lines
494 B
Python
23 lines
494 B
Python
|
|
import pytest
|
||
|
|
from fastapi.testclient import TestClient
|
||
|
|
|
||
|
|
from app import app
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture
|
||
|
|
def client():
|
||
|
|
with TestClient(app) as client:
|
||
|
|
yield client
|
||
|
|
|
||
|
|
|
||
|
|
def test_home_route(client):
|
||
|
|
response = client.get("/")
|
||
|
|
assert response.status_code == 200
|
||
|
|
assert response.json() == {"message": "Hello"}
|
||
|
|
|
||
|
|
|
||
|
|
def test_about_route(client):
|
||
|
|
response = client.get("/about")
|
||
|
|
assert response.status_code == 200
|
||
|
|
assert response.json() == {"message": "This is the about page."}
|