Skip to content

Commit dea58f5

Browse files
committed
Add test
1 parent 9421e79 commit dea58f5

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

code/function/api/v1/api_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
from function.api.v1.endpoints import heartbeat, sample
33

44
api_v1_router = APIRouter()
5-
api_v1_router.include_router(sample.router, prefix="/landingZone", tags=["sample"])
5+
api_v1_router.include_router(sample.router, prefix="/sample", tags=["sample"])
66
api_v1_router.include_router(heartbeat.router, prefix="/health", tags=["health"])

code/function/api/v1/endpoints/sample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
router = APIRouter()
1010

1111

12-
@router.post("/create", response_model=SampleResponse, name="create")
12+
@router.post("/sample", response_model=SampleResponse, name="sample")
1313
async def post_predict(
1414
data: SampleRequest,
1515
) -> SampleResponse:

tests/test_main.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,16 @@ def test_get_heartbeat(client, version):
2020
# assert
2121
assert response.status_code == 200
2222
assert response.json() == {"isAlive": True}
23+
24+
25+
@pytest.mark.parametrize("version", ("v1",))
26+
def test_post_sample(client, version):
27+
# arrange
28+
path = f"/{version}/sample/sample"
29+
30+
# action
31+
response = client.post(path, json={"input": "Test"})
32+
33+
# assert
34+
assert response.status_code == 200
35+
assert response.json() == {"output": "Hello Test"}

0 commit comments

Comments
 (0)