diff --git a/tests/storage/test_event_push_actions.py b/tests/storage/test_event_push_actions.py
index 8430fc7ba6..b114c6fb1d 100644
--- a/tests/storage/test_event_push_actions.py
+++ b/tests/storage/test_event_push_actions.py
@@ -24,15 +24,16 @@ USER_ID = "@user:example.com"
PlAIN_NOTIF = ["notify", {"set_tweak": "highlight", "value": False}]
HIGHLIGHT = [
- "notify", {"set_tweak": "sound", "value": "default"}, {"set_tweak": "highlight"}
+ "notify",
+ {"set_tweak": "sound", "value": "default"},
+ {"set_tweak": "highlight"},
]
class EventPushActionsStoreTestCase(tests.unittest.TestCase):
-
@defer.inlineCallbacks
def setUp(self):
- hs = yield tests.utils.setup_test_homeserver()
+ hs = yield tests.utils.setup_test_homeserver(self.addCleanup)
self.store = hs.get_datastore()
@defer.inlineCallbacks
@@ -55,12 +56,11 @@ class EventPushActionsStoreTestCase(tests.unittest.TestCase):
@defer.inlineCallbacks
def _assert_counts(noitf_count, highlight_count):
counts = yield self.store.runInteraction(
- "", self.store._get_unread_counts_by_pos_txn,
- room_id, user_id, 0
+ "", self.store._get_unread_counts_by_pos_txn, room_id, user_id, 0
)
self.assertEquals(
counts,
- {"notify_count": noitf_count, "highlight_count": highlight_count}
+ {"notify_count": noitf_count, "highlight_count": highlight_count},
)
@defer.inlineCallbacks
@@ -72,11 +72,13 @@ class EventPushActionsStoreTestCase(tests.unittest.TestCase):
event.depth = stream
yield self.store.add_push_actions_to_staging(
- event.event_id, {user_id: action},
+ event.event_id, {user_id: action}
)
yield self.store.runInteraction(
- "", self.store._set_push_actions_for_event_and_users_txn,
- [(event, None)], [(event, None)],
+ "",
+ self.store._set_push_actions_for_event_and_users_txn,
+ [(event, None)],
+ [(event, None)],
)
def _rotate(stream):
@@ -86,8 +88,11 @@ class EventPushActionsStoreTestCase(tests.unittest.TestCase):
def _mark_read(stream, depth):
return self.store.runInteraction(
- "", self.store._remove_old_push_actions_before_txn,
- room_id, user_id, stream
+ "",
+ self.store._remove_old_push_actions_before_txn,
+ room_id,
+ user_id,
+ stream,
)
yield _assert_counts(0, 0)
@@ -112,9 +117,7 @@ class EventPushActionsStoreTestCase(tests.unittest.TestCase):
yield _rotate(7)
yield self.store._simple_delete(
- table="event_push_actions",
- keyvalues={"1": 1},
- desc="",
+ table="event_push_actions", keyvalues={"1": 1}, desc=""
)
yield _assert_counts(1, 0)
@@ -132,18 +135,21 @@ class EventPushActionsStoreTestCase(tests.unittest.TestCase):
@defer.inlineCallbacks
def test_find_first_stream_ordering_after_ts(self):
def add_event(so, ts):
- return self.store._simple_insert("events", {
- "stream_ordering": so,
- "received_ts": ts,
- "event_id": "event%i" % so,
- "type": "",
- "room_id": "",
- "content": "",
- "processed": True,
- "outlier": False,
- "topological_ordering": 0,
- "depth": 0,
- })
+ return self.store._simple_insert(
+ "events",
+ {
+ "stream_ordering": so,
+ "received_ts": ts,
+ "event_id": "event%i" % so,
+ "type": "",
+ "room_id": "",
+ "content": "",
+ "processed": True,
+ "outlier": False,
+ "topological_ordering": 0,
+ "depth": 0,
+ },
+ )
# start with the base case where there are no events in the table
r = yield self.store.find_first_stream_ordering_after_ts(11)
@@ -160,31 +166,27 @@ class EventPushActionsStoreTestCase(tests.unittest.TestCase):
# add a bunch of dummy events to the events table
for (stream_ordering, ts) in (
- (3, 110),
- (4, 120),
- (5, 120),
- (10, 130),
- (20, 140),
+ (3, 110),
+ (4, 120),
+ (5, 120),
+ (10, 130),
+ (20, 140),
):
yield add_event(stream_ordering, ts)
r = yield self.store.find_first_stream_ordering_after_ts(110)
- self.assertEqual(r, 3,
- "First event after 110ms should be 3, was %i" % r)
+ self.assertEqual(r, 3, "First event after 110ms should be 3, was %i" % r)
# 4 and 5 are both after 120: we want 4 rather than 5
r = yield self.store.find_first_stream_ordering_after_ts(120)
- self.assertEqual(r, 4,
- "First event after 120ms should be 4, was %i" % r)
+ self.assertEqual(r, 4, "First event after 120ms should be 4, was %i" % r)
r = yield self.store.find_first_stream_ordering_after_ts(129)
- self.assertEqual(r, 10,
- "First event after 129ms should be 10, was %i" % r)
+ self.assertEqual(r, 10, "First event after 129ms should be 10, was %i" % r)
# check we can get the last event
r = yield self.store.find_first_stream_ordering_after_ts(140)
- self.assertEqual(r, 20,
- "First event after 14ms should be 20, was %i" % r)
+ self.assertEqual(r, 20, "First event after 14ms should be 20, was %i" % r)
# off the end
r = yield self.store.find_first_stream_ordering_after_ts(160)
|