From 464dac9a85efdd82b9ff7fcf1b74f0c3a185e674 Mon Sep 17 00:00:00 2001 From: Chris Fulljames Date: Sat, 7 Feb 2026 17:44:34 -0500 Subject: [PATCH] Fix push tests --- test/test_push_notifications.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/test/test_push_notifications.py b/test/test_push_notifications.py index b62b7a3..07e9ee5 100644 --- a/test/test_push_notifications.py +++ b/test/test_push_notifications.py @@ -114,6 +114,7 @@ def test_get_settings_defaults(client, user, subid): response = client.get(f"/push-notifications/settings?subid={subid}") assert response.json["comments"] == False assert response.json["songs"] == False + assert response.json["love"] == False def test_get_settings_not_logged_in(client): response = client.get("/push-notifications/settings?subid=1") @@ -137,19 +138,20 @@ def test_update_settings_ok(client, user, subid): response = client.post( "/push-notifications/settings", headers={"Content-Type": "application/json"}, - data=json.dumps({"subid": subid, "comments": True, "songs": True})) + data=json.dumps({"subid": subid, "comments": True, "songs": True, "love": True})) assert response.json["status"] == "success" # Verify settings applied response = client.get(f"/push-notifications/settings?subid={subid}") assert response.json["comments"] == True + assert response.json["love"] == True assert response.json["songs"] == True def test_update_settings_not_logged_in(client): response = client.post( "/push-notifications/settings", headers={"Content-Type": "application/json"}, - data=json.dumps({"subid": 1, "comments": True, "songs": True})) + data=json.dumps({"subid": 1, "comments": True, "songs": True, "love": True})) assert response.status_code == 302 assert response.headers["Location"] == "/login" @@ -157,7 +159,7 @@ def test_update_settings_invalid_subid(client, user): response = client.post( "/push-notifications/settings", headers={"Content-Type": "application/json"}, - data=json.dumps({"subid": 1, "comments": True, "songs": True})) + data=json.dumps({"subid": 1, "comments": True, "songs": True, "love": True})) assert response.status_code == 404 def test_update_settings_other_users_subid(client, user, subid): @@ -165,20 +167,26 @@ def test_update_settings_other_users_subid(client, user, subid): response = client.post( "/push-notifications/settings", headers={"Content-Type": "application/json"}, - data=json.dumps({"subid": subid, "comments": True, "songs": True})) + data=json.dumps({"subid": subid, "comments": True, "songs": True, "love": True})) assert response.status_code == 404 def test_update_settings_missing_value(client, user, subid): response = client.post( "/push-notifications/settings", headers={"Content-Type": "application/json"}, - data=json.dumps({"subid": subid, "comments": True})) # Missing songs + data=json.dumps({"subid": subid, "comments": True, "love": True})) # Missing songs assert response.status_code == 400 response = client.post( "/push-notifications/settings", headers={"Content-Type": "application/json"}, - data=json.dumps({"subid": subid, "songs": True})) # Missing comments + data=json.dumps({"subid": subid, "songs": True, "love": True})) # Missing comments + assert response.status_code == 400 + + response = client.post( + "/push-notifications/settings", + headers={"Content-Type": "application/json"}, + data=json.dumps({"subid": subid, "comments": True, "songs": True})) # Missing love assert response.status_code == 400 ################################################################################ @@ -193,7 +201,7 @@ def _enable_notifications(client, subid, **kwargs): @mock.patch("pywebpush.webpush") def test_notification_for_new_songs_enabled(pushmock, app, client, user, subid, vapid_keys): - _enable_notifications(client, subid, comments=False, songs=True) + _enable_notifications(client, subid, comments=False, songs=True, love=False) create_user_and_song(client, "user2") with app.app_context(): @@ -208,7 +216,7 @@ def test_notification_for_new_songs_enabled(pushmock, app, client, user, subid, @mock.patch("pywebpush.webpush") def test_notification_for_new_songs_disabled(pushmock, app, client, user, subid, vapid_keys): - _enable_notifications(client, subid, comments=False, songs=False) + _enable_notifications(client, subid, comments=False, songs=False, love=False) create_user_and_song(client, "user2") with app.app_context(): @@ -219,7 +227,7 @@ def test_notification_for_new_songs_disabled(pushmock, app, client, user, subid, @mock.patch("pywebpush.webpush") def test_notification_for_comments_enabled(pushmock, app, client, user, subid, vapid_keys): - _enable_notifications(client, subid, comments=True, songs=False) + _enable_notifications(client, subid, comments=True, songs=False, love=False) # user2 comments on user's profile create_user(client, "user2", login=True) @@ -236,7 +244,7 @@ def test_notification_for_comments_enabled(pushmock, app, client, user, subid, v @mock.patch("pywebpush.webpush") def test_notification_for_comments_disabled(pushmock, app, client, user, subid, vapid_keys): - _enable_notifications(client, subid, comments=False, songs=False) + _enable_notifications(client, subid, comments=False, songs=False, love=False) create_user(client, "user2", login=True) response = client.get("/comment?threadid=1", headers={"Referer": "/users/user1"}) response = client.post("/comment?threadid=1", data={"content": "comment on profile"}, follow_redirects=True) @@ -249,7 +257,7 @@ def test_notification_for_comments_disabled(pushmock, app, client, user, subid, @mock.patch("pywebpush.webpush") def test_subscription_deleted_on_410(pushmock, app, client, user, subid, vapid_keys): - _enable_notifications(client, subid, comments=False, songs=True) + _enable_notifications(client, subid, comments=False, songs=True, love=False) create_user_and_song(client, "user2") with app.app_context(): @@ -276,7 +284,7 @@ def test_subscription_deleted_on_410(pushmock, app, client, user, subid, vapid_k @mock.patch("pywebpush.webpush") def test_subscription_not_deleted_on_500(pushmock, app, client, user, subid, vapid_keys): - _enable_notifications(client, subid, comments=False, songs=True) + _enable_notifications(client, subid, comments=False, songs=True, love=False) create_user_and_song(client, "user2") with app.app_context(): -- 2.39.5