From 63d7d219914733bdb663c6816f2d23654054d3e8 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Mon, 14 Jul 2025 17:09:30 -0400 Subject: [PATCH] test: ensure notifications endpoint leaves current message --- src/tests/test_api_notifications.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/tests/test_api_notifications.py b/src/tests/test_api_notifications.py index fe81046..e0805a9 100644 --- a/src/tests/test_api_notifications.py +++ b/src/tests/test_api_notifications.py @@ -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