Merge pull request #547 from PR0M3TH3AN/codex/ensure-notifications-api-functionality

Add test for API notifications persistence
This commit is contained in:
thePR0M3TH3AN
2025-07-14 17:13:24 -04:00
committed by GitHub

View File

@@ -28,3 +28,18 @@ def test_notifications_endpoint_clears_queue(client):
assert api._pm.notifications.empty()
res = cl.get("/api/v1/notifications", headers={"Authorization": f"Bearer {token}"})
assert res.json() == []
def test_notifications_endpoint_does_not_clear_current(client):
cl, token = client
api._pm.notifications = queue.Queue()
msg = SimpleNamespace(message="keep", level="INFO")
api._pm.notifications.put(msg)
api._pm._current_notification = msg
api._pm.get_current_notification = lambda: api._pm._current_notification
res = cl.get("/api/v1/notifications", headers={"Authorization": f"Bearer {token}"})
assert res.status_code == 200
assert res.json() == [{"level": "INFO", "message": "keep"}]
assert api._pm.notifications.empty()
assert api._pm.get_current_notification() is msg