Skip to content

Commit 6399b0e

Browse files
committed
feat: add initial unit tests
1 parent 88f1a28 commit 6399b0e

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

pytest.ini

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[pytest]
2+
pythonpath = .
3+
testpaths = tests
4+
addopts = -v -ra -q

requirements-dev.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
httpx
2+
pytest

tests/test_api.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from fastapi.testclient import TestClient
2+
from api.server import app
3+
4+
client = TestClient(app)
5+
6+
7+
def test_read_root():
8+
response = client.get("/")
9+
assert response.status_code == 200
10+
assert response.json() == {
11+
"message": "Hello from FastAPI"
12+
} # Updated expected message
13+
14+
15+
def test_demo_post():
16+
response = client.post("/demo_post", json={"data": "test"})
17+
assert response.status_code == 200
18+
assert response.json() == {"message": "Received data: test"}

tests/test_streamlit_app.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import streamlit as st
2+
from streamlit.testing.v1 import AppTest
3+
4+
5+
def test_streamlit_app():
6+
# Create an instance of AppTest from file
7+
at = AppTest.from_file("app/streamlit_app.py")
8+
9+
# Run the app
10+
at.run()
11+
12+
print("test_streamlit_app completed successfully")

0 commit comments

Comments
 (0)