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")
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"
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):
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
################################################################################
@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():
@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():
@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)
@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)
@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():
@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():