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

Commit d3d8468

Browse files
authored
Add type hints to event push actions tests. (#13099)
1 parent b26cbe3 commit d3d8468

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

changelog.d/12985.misc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Add type annotations to `tests.state.test_v2`.
1+
Add type hints to tests.

changelog.d/13099.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add type hints to tests.

tests/storage/test_event_push_actions.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414

1515
from unittest.mock import Mock
1616

17+
from twisted.test.proto_helpers import MemoryReactor
18+
19+
from synapse.server import HomeServer
1720
from synapse.storage.databases.main.event_push_actions import NotifCounts
21+
from synapse.util import Clock
1822

1923
from tests.unittest import HomeserverTestCase
2024

@@ -29,31 +33,33 @@
2933

3034

3135
class EventPushActionsStoreTestCase(HomeserverTestCase):
32-
def prepare(self, reactor, clock, hs):
36+
def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None:
3337
self.store = hs.get_datastores().main
34-
self.persist_events_store = hs.get_datastores().persist_events
38+
persist_events_store = hs.get_datastores().persist_events
39+
assert persist_events_store is not None
40+
self.persist_events_store = persist_events_store
3541

36-
def test_get_unread_push_actions_for_user_in_range_for_http(self):
42+
def test_get_unread_push_actions_for_user_in_range_for_http(self) -> None:
3743
self.get_success(
3844
self.store.get_unread_push_actions_for_user_in_range_for_http(
3945
USER_ID, 0, 1000, 20
4046
)
4147
)
4248

43-
def test_get_unread_push_actions_for_user_in_range_for_email(self):
49+
def test_get_unread_push_actions_for_user_in_range_for_email(self) -> None:
4450
self.get_success(
4551
self.store.get_unread_push_actions_for_user_in_range_for_email(
4652
USER_ID, 0, 1000, 20
4753
)
4854
)
4955

50-
def test_count_aggregation(self):
56+
def test_count_aggregation(self) -> None:
5157
room_id = "!foo:example.com"
5258
user_id = "@user1235:example.com"
5359

5460
last_read_stream_ordering = [0]
5561

56-
def _assert_counts(noitf_count, highlight_count):
62+
def _assert_counts(noitf_count: int, highlight_count: int) -> None:
5763
counts = self.get_success(
5864
self.store.db_pool.runInteraction(
5965
"",
@@ -72,7 +78,7 @@ def _assert_counts(noitf_count, highlight_count):
7278
),
7379
)
7480

75-
def _inject_actions(stream, action):
81+
def _inject_actions(stream: int, action: list) -> None:
7682
event = Mock()
7783
event.room_id = room_id
7884
event.event_id = "$test:example.com"
@@ -96,14 +102,14 @@ def _inject_actions(stream, action):
96102
)
97103
)
98104

99-
def _rotate(stream):
105+
def _rotate(stream: int) -> None:
100106
self.get_success(
101107
self.store.db_pool.runInteraction(
102108
"", self.store._rotate_notifs_before_txn, stream
103109
)
104110
)
105111

106-
def _mark_read(stream, depth):
112+
def _mark_read(stream: int, depth: int) -> None:
107113
last_read_stream_ordering[0] = stream
108114
self.get_success(
109115
self.store.db_pool.runInteraction(
@@ -165,8 +171,8 @@ def _mark_read(stream, depth):
165171
_mark_read(10, 10)
166172
_assert_counts(0, 0)
167173

168-
def test_find_first_stream_ordering_after_ts(self):
169-
def add_event(so, ts):
174+
def test_find_first_stream_ordering_after_ts(self) -> None:
175+
def add_event(so: int, ts: int) -> None:
170176
self.get_success(
171177
self.store.db_pool.simple_insert(
172178
"events",

0 commit comments

Comments
 (0)