From fe6cb532d13b3eec0f740e2a91ec6b83ce9a22e6 Mon Sep 17 00:00:00 2001 From: Drew Bednar Date: Fri, 11 Dec 2020 22:30:20 -0500 Subject: [PATCH] Adding first test --- services/api/app/main.py | 2 +- services/api/tests/__init__.py | 0 services/api/tests/test_main.py | 11 +++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 services/api/tests/__init__.py create mode 100644 services/api/tests/test_main.py diff --git a/services/api/app/main.py b/services/api/app/main.py index f66ff13..e38afc3 100644 --- a/services/api/app/main.py +++ b/services/api/app/main.py @@ -7,4 +7,4 @@ app = FastAPI() @app.get('/ping') def pong(): now = dt.datetime.now(dt.timezone.utc) - return {"ping": "pong!", "now": now} + return {'ping': "pong!", 'now': now} diff --git a/services/api/tests/__init__.py b/services/api/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/services/api/tests/test_main.py b/services/api/tests/test_main.py new file mode 100644 index 0000000..a2f6c5a --- /dev/null +++ b/services/api/tests/test_main.py @@ -0,0 +1,11 @@ +from app.main import app +from starlette.testclient import TestClient + +client = TestClient(app) + + +def test_read_main(): + response = client.get('/ping') + assert response.status_code == 200 + data = response.json() + assert "pong" in data['ping']