Skip to content

Commit 4b964c2

Browse files
Fix /ping endpoint by removing time-based exception logic
Removed the deliberate exception that was causing the /ping endpoint to fail approximately 1/3 of the time when int(time.time()) % 3 == 0. The endpoint now reliably returns {"pong": True} on all requests. Also added test coverage for the /ping endpoint to verify correct behavior.
1 parent 12f5d2d commit 4b964c2

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

app/main.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212

1313
@app.get("/ping")
1414
def test():
15-
if int(time.time()) % 3 == 0:
16-
raise Exception("unknown internal error")
17-
1815
return {"pong": True}
1916

2017
@app.get("/hello")

app/test_main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@
77
def test_read_root():
88
response = client.get("/")
99
assert response.status_code == 200
10+
11+
def test_ping():
12+
response = client.get("/ping")
13+
assert response.status_code == 200
14+
assert response.json() == {"pong": True}

0 commit comments

Comments
 (0)