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

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Sep 23, 2022
1 parent daeacc0 commit baf8e80
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions tests/storage/test_event_push_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from twisted.test.proto_helpers import MemoryReactor

from synapse.api.constants import RelationTypes
from synapse.rest import admin
from synapse.rest.client import login, room
from synapse.server import HomeServer
Expand Down Expand Up @@ -65,16 +66,23 @@ def test_get_unread_push_actions_for_user_in_range(self) -> None:
user_id, token, _, other_token, room_id = self._create_users_and_room()

# Create two events, one of which is a highlight.
self.helper.send_event(
first_event_id = self.helper.send_event(
room_id,
type="m.room.message",
content={"msgtype": "m.text", "body": "msg"},
tok=other_token,
)
event_id = self.helper.send_event(
)["event_id"]
second_event_id = self.helper.send_event(
room_id,
type="m.room.message",
content={"msgtype": "m.text", "body": user_id},
content={
"msgtype": "m.text",
"body": user_id,
"m.relates_to": {
"rel_type": RelationTypes.THREAD,
"event_id": first_event_id,
},
},
tok=other_token,
)["event_id"]

Expand All @@ -94,13 +102,13 @@ def test_get_unread_push_actions_for_user_in_range(self) -> None:
)
self.assertEqual(2, len(email_actions))

# Send a receipt, which should clear any actions.
# Send a receipt, which should clear the first action.
self.get_success(
self.store.insert_receipt(
room_id,
"m.read",
user_id=user_id,
event_ids=[event_id],
event_ids=[first_event_id],
thread_id=None,
data={},
)
Expand All @@ -110,6 +118,30 @@ def test_get_unread_push_actions_for_user_in_range(self) -> None:
user_id, 0, 1000, 20
)
)
self.assertEqual(1, len(http_actions))
email_actions = self.get_success(
self.store.get_unread_push_actions_for_user_in_range_for_email(
user_id, 0, 1000, 20
)
)
self.assertEqual(1, len(email_actions))

# Send a thread receipt to clear the thread action.
self.get_success(
self.store.insert_receipt(
room_id,
"m.read",
user_id=user_id,
event_ids=[second_event_id],
thread_id=first_event_id,
data={},
)
)
http_actions = self.get_success(
self.store.get_unread_push_actions_for_user_in_range_for_http(
user_id, 0, 1000, 20
)
)
self.assertEqual([], http_actions)
email_actions = self.get_success(
self.store.get_unread_push_actions_for_user_in_range_for_email(
Expand Down

0 comments on commit baf8e80

Please sign in to comment.