0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-10 12:02:43 +01:00

Unbreak tests after changing storage API

This commit is contained in:
Erik Johnston 2014-09-29 15:35:57 +01:00
parent 7151615260
commit d96cb61f26
4 changed files with 53 additions and 12 deletions

View file

@ -67,7 +67,11 @@ class PresenceStateTestCase(unittest.TestCase):
self.datastore.get_presence_list = get_presence_list self.datastore.get_presence_list = get_presence_list
def _get_user_by_token(token=None): 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 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 self.datastore.has_presence_state = has_presence_state
def _get_user_by_token(token=None): 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( room_member_handler = hs.handlers.room_member_handler = Mock(
spec=[ spec=[

View file

@ -69,7 +69,11 @@ class RoomPermissionsTestCase(RestTestCase):
hs.get_handlers().federation_handler = Mock() hs.get_handlers().federation_handler = Mock()
def _get_user_by_token(token=None): 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 hs.get_auth().get_user_by_token = _get_user_by_token
self.auth_user_id = self.rmcreator_id self.auth_user_id = self.rmcreator_id
@ -425,7 +429,11 @@ class RoomsMemberListTestCase(RestTestCase):
self.auth_user_id = self.user_id self.auth_user_id = self.user_id
def _get_user_by_token(token=None): 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 hs.get_auth().get_user_by_token = _get_user_by_token
synapse.rest.room.register_servlets(hs, self.mock_resource) synapse.rest.room.register_servlets(hs, self.mock_resource)
@ -508,7 +516,11 @@ class RoomsCreateTestCase(RestTestCase):
hs.get_handlers().federation_handler = Mock() hs.get_handlers().federation_handler = Mock()
def _get_user_by_token(token=None): 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 hs.get_auth().get_user_by_token = _get_user_by_token
synapse.rest.room.register_servlets(hs, self.mock_resource) synapse.rest.room.register_servlets(hs, self.mock_resource)
@ -605,7 +617,11 @@ class RoomTopicTestCase(RestTestCase):
hs.get_handlers().federation_handler = Mock() hs.get_handlers().federation_handler = Mock()
def _get_user_by_token(token=None): 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 hs.get_auth().get_user_by_token = _get_user_by_token
synapse.rest.room.register_servlets(hs, self.mock_resource) synapse.rest.room.register_servlets(hs, self.mock_resource)
@ -715,7 +731,16 @@ class RoomMemberStateTestCase(RestTestCase):
hs.get_handlers().federation_handler = Mock() hs.get_handlers().federation_handler = Mock()
def _get_user_by_token(token=None): 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 hs.get_auth().get_user_by_token = _get_user_by_token
synapse.rest.room.register_servlets(hs, self.mock_resource) synapse.rest.room.register_servlets(hs, self.mock_resource)
@ -847,7 +872,11 @@ class RoomMessagesTestCase(RestTestCase):
hs.get_handlers().federation_handler = Mock() hs.get_handlers().federation_handler = Mock()
def _get_user_by_token(token=None): 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 hs.get_auth().get_user_by_token = _get_user_by_token
synapse.rest.room.register_servlets(hs, self.mock_resource) synapse.rest.room.register_servlets(hs, self.mock_resource)

View file

@ -53,7 +53,7 @@ class RegistrationStoreTestCase(unittest.TestCase):
) )
self.assertEquals( self.assertEquals(
self.user_id, {"admin": 0, "device_id": None, "name": self.user_id},
(yield self.store.get_user_by_token(self.tokens[0])) (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]) yield self.store.add_access_token_to_user(self.user_id, self.tokens[1])
self.assertEquals( self.assertEquals(
self.user_id, {"admin": 0, "device_id": None, "name": self.user_id},
(yield self.store.get_user_by_token(self.tokens[1])) (yield self.store.get_user_by_token(self.tokens[1]))
) )

View file

@ -167,7 +167,11 @@ class MemoryDataStore(object):
def get_user_by_token(self, token): def get_user_by_token(self, token):
try: try:
return self.tokens_to_users[token] return {
"name": self.tokens_to_users[token],
"admin": 0,
"device_id": None,
}
except: except:
raise StoreError(400, "User does not exist.") raise StoreError(400, "User does not exist.")
@ -264,7 +268,7 @@ class MemoryDataStore(object):
def get_ops_levels(self, room_id): def get_ops_levels(self, room_id):
return defer.succeed((5, 5, 5)) 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) return defer.succeed(None)