mirror of
https://gitea.publichub.eu/oscar.krause/fastapi-dls.git
synced 2024-12-27 16:08:55 +00:00
24 lines
548 B
Python
24 lines
548 B
Python
from starlette.testclient import TestClient
|
|
import importlib.util
|
|
import sys
|
|
|
|
MODULE, PATH = 'main.app', '../app/main.py'
|
|
|
|
spec = importlib.util.spec_from_file_location(MODULE, PATH)
|
|
main = importlib.util.module_from_spec(spec)
|
|
sys.modules[MODULE] = main
|
|
spec.loader.exec_module(main)
|
|
|
|
client = TestClient(main.app)
|
|
|
|
|
|
def test_index():
|
|
response = client.get('/')
|
|
assert response.status_code == 200
|
|
|
|
|
|
def test_status():
|
|
response = client.get('/status')
|
|
assert response.status_code == 200
|
|
assert response.json()['status'] == 'up'
|