Skip to content
Snippets Groups Projects
Unverified Commit 164f50f5 authored by Richard van der Hoff's avatar Richard van der Hoff Committed by GitHub
Browse files

fix mypy for tests/replication (#7518)

parent c29915bd
No related branches found
No related tags found
No related merge requests found
Fix typing annotations in `tests.replication`.
...@@ -17,11 +17,12 @@ from canonicaljson import encode_canonical_json ...@@ -17,11 +17,12 @@ from canonicaljson import encode_canonical_json
from synapse.api.room_versions import RoomVersions from synapse.api.room_versions import RoomVersions
from synapse.events import FrozenEvent, _EventInternalMetadata, make_event_from_dict from synapse.events import FrozenEvent, _EventInternalMetadata, make_event_from_dict
from synapse.events.snapshot import EventContext
from synapse.handlers.room import RoomEventSource from synapse.handlers.room import RoomEventSource
from synapse.replication.slave.storage.events import SlavedEventStore from synapse.replication.slave.storage.events import SlavedEventStore
from synapse.storage.roommember import RoomsForUser from synapse.storage.roommember import RoomsForUser
from tests.server import FakeTransport
from ._base import BaseSlavedStoreTestCase from ._base import BaseSlavedStoreTestCase
USER_ID = "@feeling:test" USER_ID = "@feeling:test"
...@@ -240,6 +241,7 @@ class SlavedEventStoreTestCase(BaseSlavedStoreTestCase): ...@@ -240,6 +241,7 @@ class SlavedEventStoreTestCase(BaseSlavedStoreTestCase):
# limit the replication rate # limit the replication rate
repl_transport = self._server_transport repl_transport = self._server_transport
assert isinstance(repl_transport, FakeTransport)
repl_transport.autoflush = False repl_transport.autoflush = False
# build the join and message events and persist them in the same batch. # build the join and message events and persist them in the same batch.
...@@ -322,7 +324,6 @@ class SlavedEventStoreTestCase(BaseSlavedStoreTestCase): ...@@ -322,7 +324,6 @@ class SlavedEventStoreTestCase(BaseSlavedStoreTestCase):
type="m.room.message", type="m.room.message",
key=None, key=None,
internal={}, internal={},
state=None,
depth=None, depth=None,
prev_events=[], prev_events=[],
auth_events=[], auth_events=[],
...@@ -362,15 +363,8 @@ class SlavedEventStoreTestCase(BaseSlavedStoreTestCase): ...@@ -362,15 +363,8 @@ class SlavedEventStoreTestCase(BaseSlavedStoreTestCase):
event = make_event_from_dict(event_dict, internal_metadata_dict=internal) event = make_event_from_dict(event_dict, internal_metadata_dict=internal)
self.event_id += 1 self.event_id += 1
state_handler = self.hs.get_state_handler()
if state is not None: context = self.get_success(state_handler.compute_event_context(event))
state_ids = {key: e.event_id for key, e in state.items()}
context = EventContext.with_state(
state_group=None, current_state_ids=state_ids, prev_state_ids=state_ids
)
else:
state_handler = self.hs.get_state_handler()
context = self.get_success(state_handler.compute_event_context(event))
self.master_store.add_push_actions_to_staging( self.master_store.add_push_actions_to_staging(
event.event_id, {user_id: actions for user_id, actions in push_actions} event.event_id, {user_id: actions for user_id, actions in push_actions}
......
...@@ -30,7 +30,7 @@ class ParseCommandTestCase(TestCase): ...@@ -30,7 +30,7 @@ class ParseCommandTestCase(TestCase):
def test_parse_rdata(self): def test_parse_rdata(self):
line = 'RDATA events master 6287863 ["ev", ["$eventid", "!roomid", "type", null, null, null]]' line = 'RDATA events master 6287863 ["ev", ["$eventid", "!roomid", "type", null, null, null]]'
cmd = parse_command_from_line(line) cmd = parse_command_from_line(line)
self.assertIsInstance(cmd, RdataCommand) assert isinstance(cmd, RdataCommand)
self.assertEqual(cmd.stream_name, "events") self.assertEqual(cmd.stream_name, "events")
self.assertEqual(cmd.instance_name, "master") self.assertEqual(cmd.instance_name, "master")
self.assertEqual(cmd.token, 6287863) self.assertEqual(cmd.token, 6287863)
...@@ -38,7 +38,7 @@ class ParseCommandTestCase(TestCase): ...@@ -38,7 +38,7 @@ class ParseCommandTestCase(TestCase):
def test_parse_rdata_batch(self): def test_parse_rdata_batch(self):
line = 'RDATA presence master batch ["@foo:example.com", "online"]' line = 'RDATA presence master batch ["@foo:example.com", "online"]'
cmd = parse_command_from_line(line) cmd = parse_command_from_line(line)
self.assertIsInstance(cmd, RdataCommand) assert isinstance(cmd, RdataCommand)
self.assertEqual(cmd.stream_name, "presence") self.assertEqual(cmd.stream_name, "presence")
self.assertEqual(cmd.instance_name, "master") self.assertEqual(cmd.instance_name, "master")
self.assertIsNone(cmd.token) self.assertIsNone(cmd.token)
...@@ -207,7 +207,7 @@ commands = mypy \ ...@@ -207,7 +207,7 @@ commands = mypy \
synapse/storage/util \ synapse/storage/util \
synapse/streams \ synapse/streams \
synapse/util/caches/stream_change_cache.py \ synapse/util/caches/stream_change_cache.py \
tests/replication/tcp/streams \ tests/replication \
tests/test_utils \ tests/test_utils \
tests/rest/client/v2_alpha/test_auth.py \ tests/rest/client/v2_alpha/test_auth.py \
tests/util/test_stream_change_cache.py tests/util/test_stream_change_cache.py
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment