summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2015-02-05 11:54:36 +0000
committerKegan Dougal <kegan@matrix.org>2015-02-05 11:54:36 +0000
commitbc658907f0195f4f5f3ec9f7730884bbd516ce79 (patch)
treed558caaad05ddfb08e4376b7a7a3d8405773ef0b /tests
parentAdd unknown room alias check. Call it from directory_handler.get_association (diff)
downloadsynapse-bc658907f0195f4f5f3ec9f7730884bbd516ce79.tar.xz
Add unit test for appservice_handler.query_room_alias_exists
Diffstat (limited to 'tests')
-rw-r--r--tests/handlers/test_appservice.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/handlers/test_appservice.py b/tests/handlers/test_appservice.py
index f92dc1c89a..fd6bcbbce6 100644
--- a/tests/handlers/test_appservice.py
+++ b/tests/handlers/test_appservice.py
@@ -37,6 +37,7 @@ class AppServiceHandlerTestCase(unittest.TestCase):
             raise Exception("Test expected handler.appservice_api to exist.")
         self.handler.appservice_api = self.mock_as_api
 
+    @defer.inlineCallbacks
     def test_notify_interested_services(self):
         interested_service = self._mkservice(is_interested=True)
         services = [
@@ -54,9 +55,37 @@ class AppServiceHandlerTestCase(unittest.TestCase):
             room_id="!foo:bar"
         )
         self.mock_as_api.push = Mock()
-        self.handler.notify_interested_services(event)
+        yield self.handler.notify_interested_services(event)
         self.mock_as_api.push.assert_called_once_with(interested_service, event)
 
+    @defer.inlineCallbacks
+    def test_query_room_alias_exists(self):
+        room_alias = "#foo:bar"
+        room_id = "!alpha:bet"
+        servers = ["aperture"]
+        interested_service = self._mkservice(is_interested=True)
+        services = [
+            self._mkservice(is_interested=False),
+            interested_service,
+            self._mkservice(is_interested=False)
+        ]
+
+        self.mock_store.get_app_services = Mock(return_value=services)
+        self.mock_store.get_association_from_room_alias = Mock(
+            return_value=Mock(room_id=room_id, servers=servers)
+        )
+
+        result = yield self.handler.query_room_alias_exists(room_alias)
+
+        self.mock_as_api.query_alias.assert_called_once_with(
+            interested_service,
+            room_alias
+        )
+        self.assertEquals(result.room_id, room_id)
+        self.assertEquals(result.servers, servers)
+
+
+
     def _mkservice(self, is_interested):
         service = Mock()
         service.is_interested = Mock(return_value=is_interested)