Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Add test for deleting push actions on receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Sep 24, 2022
1 parent 4b85442 commit ef04bc8
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/storage/test_receipts.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,46 @@ def test_get_last_receipt_event_id_for_user(self) -> None:
)
)
self.assertEqual(res, event2_1_id)

def test_receipts_clear_push_actions(self) -> None:
event_1_id = self.create_and_send_event(
self.room_id1, UserID.from_string(OTHER_USER_ID)
)
event_2_id = self.create_and_send_event(
self.room_id1, UserID.from_string(OTHER_USER_ID)
)

def _assert_push_action_count(expected: int):
result = self.get_success(
self.store.db_pool.simple_select_list(
table="event_push_actions",
keyvalues={"1": 1},
retcols=("event_id",),
desc="",
)
)
self.assertEqual(len(result), expected)

# Check we have 2 push actions pending
_assert_push_action_count(2)

# Send a read receipt for the first event
self.get_success(
self.store.insert_receipt(
self.room_id1, ReceiptTypes.READ, OUR_USER_ID, [event_1_id], {}
)
)

# Check that we now have a single push action pending
_assert_push_action_count(1)

# Send a read receipt for the second event
self.get_success(
self.store.insert_receipt(
self.room_id1, ReceiptTypes.READ, OUR_USER_ID, [event_2_id], {}
)
)

# Check that we have no push actions pending
_assert_push_action_count(0)

0 comments on commit ef04bc8

Please sign in to comment.