summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/tests/test_notifications.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/tests/test_notifications.py')
-rw-r--r--packages/meshbay-hub/tests/test_notifications.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/packages/meshbay-hub/tests/test_notifications.py b/packages/meshbay-hub/tests/test_notifications.py
index 8da589a..35ed288 100644
--- a/packages/meshbay-hub/tests/test_notifications.py
+++ b/packages/meshbay-hub/tests/test_notifications.py
@@ -92,7 +92,7 @@ async def test_notification_on_suspend(client):
@pytest.mark.asyncio
-async def test_mark_notification_read(client):
+async def test_dismissing_one_deletes_it(client):
_, admin_token = await _setup_admin(client)
uid = await _register(client, "alice", email="a@x.com")
alice_token = await _login(client, "alice")
@@ -105,6 +105,8 @@ async def test_mark_notification_read(client):
headers={"Authorization": f"Bearer {alice_token}"})
nid = r.json()["notifications"][0]["id"]
+ # `/read` is the old path and still the one older clients call. It
+ # dismisses, like DELETE — see api/notifications.py.
r = await client.post(f"/v1/notifications/{nid}/read",
headers={"Authorization": f"Bearer {alice_token}"})
assert r.status_code == 200
@@ -112,11 +114,13 @@ async def test_mark_notification_read(client):
r = await client.get("/v1/notifications",
headers={"Authorization": f"Bearer {alice_token}"})
assert r.json()["unread_count"] == 0
- assert r.json()["notifications"][0]["read"] is True
+ assert r.json()["notifications"] == [], (
+ "a dismissed notification is deleted, not kept as a row nothing can "
+ "ever show again")
@pytest.mark.asyncio
-async def test_mark_all_read(client):
+async def test_dismissing_all_deletes_them(client):
_, admin_token = await _setup_admin(client)
uid = await _register(client, "alice", email="a@x.com")
alice_token = await _login(client, "alice")
@@ -135,10 +139,13 @@ async def test_mark_all_read(client):
r = await client.post("/v1/notifications/read-all",
headers={"Authorization": f"Bearer {alice_token}"})
assert r.status_code == 200
+ assert r.json()["removed"] == 2
r = await client.get("/v1/notifications",
headers={"Authorization": f"Bearer {alice_token}"})
assert r.json()["unread_count"] == 0
+ assert r.json()["notifications"] == [], (
+ "read-all must not be the one route that still hoards rows")
@pytest.mark.asyncio