]> littlesong.place Git - littlesongplace.git/commitdiff
Fix push tests
authorChris Fulljames <christianfulljames@gmail.com>
Sat, 7 Feb 2026 22:44:34 +0000 (17:44 -0500)
committerChris Fulljames <christianfulljames@gmail.com>
Sat, 7 Feb 2026 22:44:34 +0000 (17:44 -0500)
test/test_push_notifications.py

index b62b7a3f9604662c3a791ea75ad3aa6a3bf5f0f1..07e9ee5fa7a3e0a53c8ae0d5a5ad21945be99d1e 100644 (file)
@@ -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():