Fixup tests

This commit is contained in:
Erik Johnston 2019-12-05 15:53:10 +00:00
parent 1a0997bbd5
commit 4ca3ef10b9
3 changed files with 15 additions and 2 deletions

View File

@ -15,6 +15,8 @@
from mock import Mock from mock import Mock
from twisted.internet import defer
from synapse.rest.client.v1 import presence from synapse.rest.client.v1 import presence
from synapse.types import UserID from synapse.types import UserID
@ -36,6 +38,7 @@ class PresenceTestCase(unittest.HomeserverTestCase):
) )
hs.presence_handler = Mock() hs.presence_handler = Mock()
hs.presence_handler.set_state.return_value = defer.succeed(None)
return hs return hs

View File

@ -52,6 +52,14 @@ class MockHandlerProfileTestCase(unittest.TestCase):
] ]
) )
self.mock_handler.get_displayname.return_value = defer.succeed(Mock())
self.mock_handler.set_displayname.return_value = defer.succeed(Mock())
self.mock_handler.get_avatar_url.return_value = defer.succeed(Mock())
self.mock_handler.set_avatar_url.return_value = defer.succeed(Mock())
self.mock_handler.check_profile_query_allowed.return_value = defer.succeed(
Mock()
)
hs = yield setup_test_homeserver( hs = yield setup_test_homeserver(
self.addCleanup, self.addCleanup,
"test", "test",
@ -63,7 +71,7 @@ class MockHandlerProfileTestCase(unittest.TestCase):
) )
def _get_user_by_req(request=None, allow_guest=False): def _get_user_by_req(request=None, allow_guest=False):
return synapse.types.create_requester(myid) return defer.succeed(synapse.types.create_requester(myid))
hs.get_auth().get_user_by_req = _get_user_by_req hs.get_auth().get_user_by_req = _get_user_by_req

View File

@ -461,7 +461,9 @@ class MockHttpResource(HttpServer):
try: try:
args = [urlparse.unquote(u) for u in matcher.groups()] args = [urlparse.unquote(u) for u in matcher.groups()]
(code, response) = yield func(mock_request, *args) (code, response) = yield defer.ensureDeferred(
func(mock_request, *args)
)
return code, response return code, response
except CodeMessageException as e: except CodeMessageException as e:
return (e.code, cs_error(e.msg, code=e.errcode)) return (e.code, cs_error(e.msg, code=e.errcode))