diff --git a/tests/handlers/test_typing.py b/tests/handlers/test_typing.py
index 6a498b23a4..bf34b7ccbd 100644
--- a/tests/handlers/test_typing.py
+++ b/tests/handlers/test_typing.py
@@ -20,13 +20,15 @@ from twisted.internet import defer
from mock import Mock, call, ANY
import json
-from ..utils import MockHttpResource, MockClock, DeferredMockCallable, MockKey
+from ..utils import (
+ MockHttpResource, MockClock, DeferredMockCallable, setup_test_homeserver
+)
from synapse.api.errors import AuthError
-from synapse.server import HomeServer
from synapse.handlers.typing import TypingNotificationHandler
from synapse.storage.transactions import DestinationsTable
+from synapse.types import UserID
def _expect_edu(destination, edu_type, content, origin="test"):
@@ -55,6 +57,7 @@ class JustTypingNotificationHandlers(object):
class TypingNotificationsTestCase(unittest.TestCase):
"""Tests typing notifications to rooms."""
+ @defer.inlineCallbacks
def setUp(self):
self.clock = MockClock()
@@ -63,34 +66,29 @@ class TypingNotificationsTestCase(unittest.TestCase):
self.mock_federation_resource = MockHttpResource()
- self.mock_config = Mock()
- self.mock_config.signing_key = [MockKey()]
-
mock_notifier = Mock(spec=["on_new_user_event"])
self.on_new_user_event = mock_notifier.on_new_user_event
self.auth = Mock(spec=[])
- hs = HomeServer("test",
- auth=self.auth,
- clock=self.clock,
- db_pool=None,
- datastore=Mock(spec=[
- # Bits that Federation needs
- "prep_send_transaction",
- "delivered_txn",
- "get_received_txn_response",
- "set_received_txn_response",
- "get_destination_retry_timings",
- ]),
- handlers=None,
- notifier=mock_notifier,
- resource_for_client=Mock(),
- resource_for_federation=self.mock_federation_resource,
- http_client=self.mock_http_client,
- config=self.mock_config,
- keyring=Mock(),
- )
+ hs = yield setup_test_homeserver(
+ auth=self.auth,
+ clock=self.clock,
+ datastore=Mock(spec=[
+ # Bits that Federation needs
+ "prep_send_transaction",
+ "delivered_txn",
+ "get_received_txn_response",
+ "set_received_txn_response",
+ "get_destination_retry_timings",
+ ]),
+ handlers=None,
+ notifier=mock_notifier,
+ resource_for_client=Mock(),
+ resource_for_federation=self.mock_federation_resource,
+ http_client=self.mock_http_client,
+ keyring=Mock(),
+ )
hs.handlers = JustTypingNotificationHandlers(hs)
self.handler = hs.get_handlers().typing_notification_handler
@@ -153,11 +151,11 @@ class TypingNotificationsTestCase(unittest.TestCase):
self.auth.check_joined_room = check_joined_room
# Some local users to test with
- self.u_apple = hs.parse_userid("@apple:test")
- self.u_banana = hs.parse_userid("@banana:test")
+ self.u_apple = UserID.from_string("@apple:test")
+ self.u_banana = UserID.from_string("@banana:test")
# Remote user
- self.u_onion = hs.parse_userid("@onion:farm")
+ self.u_onion = UserID.from_string("@onion:farm")
@defer.inlineCallbacks
def test_started_typing_local(self):
|