Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
d3d84685
Unverified
Commit
d3d84685
authored
2 years ago
by
Patrick Cloke
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add type hints to event push actions tests. (#13099)
parent
b26cbe3d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/12985.misc
+1
-1
1 addition, 1 deletion
changelog.d/12985.misc
changelog.d/13099.misc
+1
-0
1 addition, 0 deletions
changelog.d/13099.misc
tests/storage/test_event_push_actions.py
+17
-11
17 additions, 11 deletions
tests/storage/test_event_push_actions.py
with
19 additions
and
12 deletions
changelog.d/12985.misc
+
1
−
1
View file @
d3d84685
Add type
annotation
s to
`
tests.
state.test_v2`.
Add type
hint
s to tests.
This diff is collapsed.
Click to expand it.
changelog.d/13099.misc
0 → 100644
+
1
−
0
View file @
d3d84685
Add type hints to tests.
This diff is collapsed.
Click to expand it.
tests/storage/test_event_push_actions.py
+
17
−
11
View file @
d3d84685
...
...
@@ -14,7 +14,11 @@
from
unittest.mock
import
Mock
from
twisted.test.proto_helpers
import
MemoryReactor
from
synapse.server
import
HomeServer
from
synapse.storage.databases.main.event_push_actions
import
NotifCounts
from
synapse.util
import
Clock
from
tests.unittest
import
HomeserverTestCase
...
...
@@ -29,31 +33,33 @@ HIGHLIGHT = [
class
EventPushActionsStoreTestCase
(
HomeserverTestCase
):
def
prepare
(
self
,
reactor
,
clock
,
hs
)
:
def
prepare
(
self
,
reactor
:
MemoryReactor
,
clock
:
Clock
,
hs
:
HomeServer
)
->
None
:
self
.
store
=
hs
.
get_datastores
().
main
self
.
persist_events_store
=
hs
.
get_datastores
().
persist_events
persist_events_store
=
hs
.
get_datastores
().
persist_events
assert
persist_events_store
is
not
None
self
.
persist_events_store
=
persist_events_store
def
test_get_unread_push_actions_for_user_in_range_for_http
(
self
):
def
test_get_unread_push_actions_for_user_in_range_for_http
(
self
)
->
None
:
self
.
get_success
(
self
.
store
.
get_unread_push_actions_for_user_in_range_for_http
(
USER_ID
,
0
,
1000
,
20
)
)
def
test_get_unread_push_actions_for_user_in_range_for_email
(
self
):
def
test_get_unread_push_actions_for_user_in_range_for_email
(
self
)
->
None
:
self
.
get_success
(
self
.
store
.
get_unread_push_actions_for_user_in_range_for_email
(
USER_ID
,
0
,
1000
,
20
)
)
def
test_count_aggregation
(
self
):
def
test_count_aggregation
(
self
)
->
None
:
room_id
=
"
!foo:example.com
"
user_id
=
"
@user1235:example.com
"
last_read_stream_ordering
=
[
0
]
def
_assert_counts
(
noitf_count
,
highlight_count
)
:
def
_assert_counts
(
noitf_count
:
int
,
highlight_count
:
int
)
->
None
:
counts
=
self
.
get_success
(
self
.
store
.
db_pool
.
runInteraction
(
""
,
...
...
@@ -72,7 +78,7 @@ class EventPushActionsStoreTestCase(HomeserverTestCase):
),
)
def
_inject_actions
(
stream
,
action
)
:
def
_inject_actions
(
stream
:
int
,
action
:
list
)
->
None
:
event
=
Mock
()
event
.
room_id
=
room_id
event
.
event_id
=
"
$test:example.com
"
...
...
@@ -96,14 +102,14 @@ class EventPushActionsStoreTestCase(HomeserverTestCase):
)
)
def
_rotate
(
stream
)
:
def
_rotate
(
stream
:
int
)
->
None
:
self
.
get_success
(
self
.
store
.
db_pool
.
runInteraction
(
""
,
self
.
store
.
_rotate_notifs_before_txn
,
stream
)
)
def
_mark_read
(
stream
,
depth
)
:
def
_mark_read
(
stream
:
int
,
depth
:
int
)
->
None
:
last_read_stream_ordering
[
0
]
=
stream
self
.
get_success
(
self
.
store
.
db_pool
.
runInteraction
(
...
...
@@ -165,8 +171,8 @@ class EventPushActionsStoreTestCase(HomeserverTestCase):
_mark_read
(
10
,
10
)
_assert_counts
(
0
,
0
)
def
test_find_first_stream_ordering_after_ts
(
self
):
def
add_event
(
so
,
ts
)
:
def
test_find_first_stream_ordering_after_ts
(
self
)
->
None
:
def
add_event
(
so
:
int
,
ts
:
int
)
->
None
:
self
.
get_success
(
self
.
store
.
db_pool
.
simple_insert
(
"
events
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment