worker: Ensure complete coverage for PushNotificationsWorker.

The `# nocoverage` was unnecessary apart from for the compatibility code,
so add a test for that code and remove the `# nocoverage`.

The `message_id` -> `message_ids` conversion was done in
9869153ae8.
This commit is contained in:
Abhijeet Prasad Bodas
2021-07-13 15:22:36 +05:30
committed by Tim Abbott
parent 801ebba7c7
commit e63e86dcb2
2 changed files with 25 additions and 2 deletions

View File

@@ -667,7 +667,7 @@ class EmailSendingWorker(LoopQueueProcessingWorker):
@assign_queue("missedmessage_mobile_notifications")
class PushNotificationsWorker(QueueProcessingWorker): # nocoverage
class PushNotificationsWorker(QueueProcessingWorker):
def start(self) -> None:
# initialize_push_notifications doesn't strictly do anything
# beyond printing some logging warnings if push notifications
@@ -679,7 +679,13 @@ class PushNotificationsWorker(QueueProcessingWorker): # nocoverage
try:
if event.get("type", "add") == "remove":
message_ids = event.get("message_ids")
if message_ids is None: # legacy task across an upgrade
if message_ids is None:
# TODO/compatibility: Previously, we sent only one `message_id` in
# a payload for notification remove events. This was later changed
# to send a list of `message_ids` (with that field name), but we need
# compatibility code for events present in the queue during upgrade.
# Remove this when one can no longer upgrade from 1.9.2 (or earlier)
# to any version after 2.0.0
message_ids = [event["message_id"]]
handle_remove_push_notification(event["user_profile_id"], message_ids)
else: