mirror of
https://git.collinwebdesigns.de/oscar.krause/fastapi-dls.git
synced 2024-11-23 23:41:06 +03: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'
|