summary refs log tree commit diff
path: root/tests/handlers/test_typing.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-02-11 11:37:30 +0000
committerMark Haines <mark.haines@matrix.org>2015-02-11 11:37:30 +0000
commit896253e085751df88e747b29e638916b15cf7a0e (patch)
treeea62bdb8650946adfa6c9dc4603ce87a39e55e3e /tests/handlers/test_typing.py
parentMerge pull request #60 from matrix-org/single_source_version_and_dependencies (diff)
downloadsynapse-896253e085751df88e747b29e638916b15cf7a0e.tar.xz
Factor out some of the common homeserver setup code into a
setup_test_homeserver function in utils.
Diffstat (limited to 'tests/handlers/test_typing.py')
-rw-r--r--tests/handlers/test_typing.py47
1 files changed, 22 insertions, 25 deletions
diff --git a/tests/handlers/test_typing.py b/tests/handlers/test_typing.py
index 8a7fc028d1..bf34b7ccbd 100644
--- a/tests/handlers/test_typing.py
+++ b/tests/handlers/test_typing.py
@@ -20,10 +20,11 @@ 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
@@ -56,6 +57,7 @@ class JustTypingNotificationHandlers(object):
 
 class TypingNotificationsTestCase(unittest.TestCase):
     """Tests typing notifications to rooms."""
+    @defer.inlineCallbacks
     def setUp(self):
         self.clock = MockClock()
 
@@ -64,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