summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-09-29 15:35:57 +0100
committerErik Johnston <erik@matrix.org>2014-09-29 15:35:57 +0100
commitd96cb61f26fa5ed3f0aab9b4c461e9656d986194 (patch)
tree279d3b8efd4c9ec32d55703cee8b659f4792fa10
parentUpdate docstring (diff)
downloadsynapse-d96cb61f26fa5ed3f0aab9b4c461e9656d986194.tar.xz
Unbreak tests after changing storage API
-rw-r--r--tests/rest/test_presence.py12
-rw-r--r--tests/rest/test_rooms.py41
-rw-r--r--tests/storage/test_registration.py4
-rw-r--r--tests/utils.py8
4 files changed, 53 insertions, 12 deletions
diff --git a/tests/rest/test_presence.py b/tests/rest/test_presence.py
index 1b3e6759c2..e2dc3dec81 100644
--- a/tests/rest/test_presence.py
+++ b/tests/rest/test_presence.py
@@ -67,7 +67,11 @@ class PresenceStateTestCase(unittest.TestCase):
         self.datastore.get_presence_list = get_presence_list
 
         def _get_user_by_token(token=None):
-            return hs.parse_userid(myid)
+            return {
+                "user": hs.parse_userid(myid),
+                "admin": False,
+                "device_id": None,
+            }
 
         hs.get_auth().get_user_by_token = _get_user_by_token
 
@@ -151,7 +155,11 @@ class PresenceListTestCase(unittest.TestCase):
         self.datastore.has_presence_state = has_presence_state
 
         def _get_user_by_token(token=None):
-            return hs.parse_userid(myid)
+            return {
+                "user": hs.parse_userid(myid),
+                "admin": False,
+                "device_id": None,
+            }
 
         room_member_handler = hs.handlers.room_member_handler = Mock(
             spec=[
diff --git a/tests/rest/test_rooms.py b/tests/rest/test_rooms.py
index 4ea5828d4f..1ce9b8a83d 100644
--- a/tests/rest/test_rooms.py
+++ b/tests/rest/test_rooms.py
@@ -69,7 +69,11 @@ class RoomPermissionsTestCase(RestTestCase):
         hs.get_handlers().federation_handler = Mock()
 
         def _get_user_by_token(token=None):
-            return hs.parse_userid(self.auth_user_id)
+            return {
+                "user": hs.parse_userid(self.auth_user_id),
+                "admin": False,
+                "device_id": None,
+            }
         hs.get_auth().get_user_by_token = _get_user_by_token
 
         self.auth_user_id = self.rmcreator_id
@@ -425,7 +429,11 @@ class RoomsMemberListTestCase(RestTestCase):
         self.auth_user_id = self.user_id
 
         def _get_user_by_token(token=None):
-            return hs.parse_userid(self.auth_user_id)
+            return {
+                "user": hs.parse_userid(self.auth_user_id),
+                "admin": False,
+                "device_id": None,
+            }
         hs.get_auth().get_user_by_token = _get_user_by_token
 
         synapse.rest.room.register_servlets(hs, self.mock_resource)
@@ -508,7 +516,11 @@ class RoomsCreateTestCase(RestTestCase):
         hs.get_handlers().federation_handler = Mock()
 
         def _get_user_by_token(token=None):
-            return hs.parse_userid(self.auth_user_id)
+            return {
+                "user": hs.parse_userid(self.auth_user_id),
+                "admin": False,
+                "device_id": None,
+            }
         hs.get_auth().get_user_by_token = _get_user_by_token
 
         synapse.rest.room.register_servlets(hs, self.mock_resource)
@@ -605,7 +617,11 @@ class RoomTopicTestCase(RestTestCase):
         hs.get_handlers().federation_handler = Mock()
 
         def _get_user_by_token(token=None):
-            return hs.parse_userid(self.auth_user_id)
+            return {
+                "user": hs.parse_userid(self.auth_user_id),
+                "admin": False,
+                "device_id": None,
+            }
         hs.get_auth().get_user_by_token = _get_user_by_token
 
         synapse.rest.room.register_servlets(hs, self.mock_resource)
@@ -715,7 +731,16 @@ class RoomMemberStateTestCase(RestTestCase):
         hs.get_handlers().federation_handler = Mock()
 
         def _get_user_by_token(token=None):
-            return hs.parse_userid(self.auth_user_id)
+            return {
+                "user": hs.parse_userid(self.auth_user_id),
+                "admin": False,
+                "device_id": None,
+            }
+            return {
+                "user": hs.parse_userid(self.auth_user_id),
+                "admin": False,
+                "device_id": None,
+            }
         hs.get_auth().get_user_by_token = _get_user_by_token
 
         synapse.rest.room.register_servlets(hs, self.mock_resource)
@@ -847,7 +872,11 @@ class RoomMessagesTestCase(RestTestCase):
         hs.get_handlers().federation_handler = Mock()
 
         def _get_user_by_token(token=None):
-            return hs.parse_userid(self.auth_user_id)
+            return {
+                "user": hs.parse_userid(self.auth_user_id),
+                "admin": False,
+                "device_id": None,
+            }
         hs.get_auth().get_user_by_token = _get_user_by_token
 
         synapse.rest.room.register_servlets(hs, self.mock_resource)
diff --git a/tests/storage/test_registration.py b/tests/storage/test_registration.py
index 91e221d53e..84bfde7568 100644
--- a/tests/storage/test_registration.py
+++ b/tests/storage/test_registration.py
@@ -53,7 +53,7 @@ class RegistrationStoreTestCase(unittest.TestCase):
         )
 
         self.assertEquals(
-            self.user_id,
+            {"admin": 0, "device_id": None, "name": self.user_id},
             (yield self.store.get_user_by_token(self.tokens[0]))
         )
 
@@ -63,7 +63,7 @@ class RegistrationStoreTestCase(unittest.TestCase):
         yield self.store.add_access_token_to_user(self.user_id, self.tokens[1])
 
         self.assertEquals(
-            self.user_id,
+            {"admin": 0, "device_id": None, "name": self.user_id},
             (yield self.store.get_user_by_token(self.tokens[1]))
         )
 
diff --git a/tests/utils.py b/tests/utils.py
index ae97621147..e7c4bc4cad 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -167,7 +167,11 @@ class MemoryDataStore(object):
 
     def get_user_by_token(self, token):
         try:
-            return self.tokens_to_users[token]
+            return {
+                "name": self.tokens_to_users[token],
+                "admin": 0,
+                "device_id": None,
+            }
         except:
             raise StoreError(400, "User does not exist.")
 
@@ -264,7 +268,7 @@ class MemoryDataStore(object):
     def get_ops_levels(self, room_id):
         return defer.succeed((5, 5, 5))
 
-    def insert_client_ip(self, user, access_token, ip_addr):
+    def insert_client_ip(self, user, device_id, access_token, ip, user_agent):
         return defer.succeed(None)