mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-21 17:15:38 +03:00
Removed http_server from HomeServer. Updated unit tests to use either resource_for_federation or resource_for_client depending on what is being tested.
This commit is contained in:
parent
29aa13f0d4
commit
9a1638ed21
12 changed files with 21 additions and 30 deletions
|
@ -24,7 +24,7 @@ from twisted.python.log import PythonLoggingObserver
|
|||
from twisted.web.resource import Resource
|
||||
from twisted.web.static import File
|
||||
from twisted.web.server import Site
|
||||
from synapse.http.server import TwistedHttpServer, JsonResource
|
||||
from synapse.http.server import JsonResource
|
||||
from synapse.http.client import TwistedHttpClient
|
||||
from synapse.rest.base import CLIENT_PREFIX
|
||||
from synapse.federation.transport import PREFIX
|
||||
|
@ -40,8 +40,6 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class SynapseHomeServer(HomeServer):
|
||||
def build_http_server(self):
|
||||
return TwistedHttpServer()
|
||||
|
||||
def build_http_client(self):
|
||||
return TwistedHttpClient()
|
||||
|
|
|
@ -52,10 +52,9 @@ class HttpServer(object):
|
|||
pass
|
||||
|
||||
|
||||
# The actual HTTP server impl, using twisted http server
|
||||
class TwistedHttpServer(HttpServer, resource.Resource):
|
||||
""" This wraps the twisted HTTP server, and triggers the correct callbacks
|
||||
on the transport_layer.
|
||||
class JsonResource(HttpServer, resource.Resource):
|
||||
""" This implements the HttpServer interface and provides JSON support for
|
||||
Resources.
|
||||
|
||||
Register callbacks via register_path()
|
||||
"""
|
||||
|
@ -185,8 +184,3 @@ def respond_with_json_bytes(request, code, json_bytes, send_cors=False):
|
|||
request.write(json_bytes)
|
||||
request.finish()
|
||||
return NOT_DONE_YET
|
||||
|
||||
|
||||
# FIXME: Temp, just so the new name can be used without breaking the world.
|
||||
class JsonResource(TwistedHttpServer):
|
||||
pass
|
|
@ -55,7 +55,6 @@ class BaseHomeServer(object):
|
|||
|
||||
DEPENDENCIES = [
|
||||
'clock',
|
||||
'http_server',
|
||||
'http_client',
|
||||
'db_pool',
|
||||
'persistence_service',
|
||||
|
@ -138,7 +137,9 @@ class HomeServer(BaseHomeServer):
|
|||
required.
|
||||
|
||||
It still requires the following to be specified by the caller:
|
||||
http_server
|
||||
resource_for_client
|
||||
resource_for_web_client
|
||||
resource_for_federation
|
||||
http_client
|
||||
db_pool
|
||||
"""
|
||||
|
|
|
@ -70,7 +70,7 @@ class FederationTestCase(unittest.TestCase):
|
|||
)
|
||||
self.clock = MockClock()
|
||||
hs = HomeServer("test",
|
||||
http_server=self.mock_http_server,
|
||||
resource_for_federation=self.mock_http_server,
|
||||
http_client=self.mock_http_client,
|
||||
db_pool=None,
|
||||
datastore=self.mock_persistence,
|
||||
|
|
|
@ -51,7 +51,7 @@ class DirectoryTestCase(unittest.TestCase):
|
|||
"get_association_from_room_alias",
|
||||
]),
|
||||
http_client=None,
|
||||
http_server=Mock(),
|
||||
resource_for_federation=Mock(),
|
||||
replication_layer=self.mock_federation,
|
||||
)
|
||||
hs.handlers = DirectoryHandlers(hs)
|
||||
|
|
|
@ -42,7 +42,7 @@ class FederationTestCase(unittest.TestCase):
|
|||
"persist_event",
|
||||
"store_room",
|
||||
]),
|
||||
http_server=NonCallableMock(),
|
||||
resource_for_federation=NonCallableMock(),
|
||||
http_client=NonCallableMock(spec_set=[]),
|
||||
notifier=NonCallableMock(spec_set=["on_new_room_event"]),
|
||||
handlers=NonCallableMock(spec_set=[
|
||||
|
|
|
@ -66,7 +66,7 @@ class PresenceStateTestCase(unittest.TestCase):
|
|||
"set_presence_list_accepted",
|
||||
]),
|
||||
handlers=None,
|
||||
http_server=Mock(),
|
||||
resource_for_federation=Mock(),
|
||||
http_client=None,
|
||||
)
|
||||
hs.handlers = JustPresenceHandlers(hs)
|
||||
|
@ -188,7 +188,7 @@ class PresenceInvitesTestCase(unittest.TestCase):
|
|||
"del_presence_list",
|
||||
]),
|
||||
handlers=None,
|
||||
http_server=Mock(),
|
||||
resource_for_client=Mock(),
|
||||
http_client=None,
|
||||
replication_layer=self.replication
|
||||
)
|
||||
|
@ -402,7 +402,7 @@ class PresencePushTestCase(unittest.TestCase):
|
|||
"set_presence_state",
|
||||
]),
|
||||
handlers=None,
|
||||
http_server=Mock(),
|
||||
resource_for_client=Mock(),
|
||||
http_client=None,
|
||||
replication_layer=self.replication,
|
||||
)
|
||||
|
@ -727,7 +727,7 @@ class PresencePollingTestCase(unittest.TestCase):
|
|||
db_pool=None,
|
||||
datastore=Mock(spec=[]),
|
||||
handlers=None,
|
||||
http_server=Mock(),
|
||||
resource_for_client=Mock(),
|
||||
http_client=None,
|
||||
replication_layer=self.replication,
|
||||
)
|
||||
|
|
|
@ -71,7 +71,7 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase):
|
|||
"set_profile_displayname",
|
||||
]),
|
||||
handlers=None,
|
||||
http_server=Mock(),
|
||||
resource_for_federation=Mock(),
|
||||
http_client=None,
|
||||
replication_layer=MockReplication(),
|
||||
)
|
||||
|
|
|
@ -56,7 +56,7 @@ class ProfileTestCase(unittest.TestCase):
|
|||
"set_profile_avatar_url",
|
||||
]),
|
||||
handlers=None,
|
||||
http_server=Mock(),
|
||||
resource_for_federation=Mock(),
|
||||
replication_layer=self.mock_federation,
|
||||
)
|
||||
hs.handlers = ProfileHandlers(hs)
|
||||
|
@ -139,7 +139,7 @@ class ProfileTestCase(unittest.TestCase):
|
|||
mocked_set = self.datastore.set_profile_avatar_url
|
||||
mocked_set.return_value = defer.succeed(())
|
||||
|
||||
yield self.handler.set_avatar_url(self.frank, self.frank,
|
||||
yield self.handler.set_avatar_url(self.frank, self.frank,
|
||||
"http://my.server/pic.gif")
|
||||
|
||||
mocked_set.assert_called_with("1234ABCD", "http://my.server/pic.gif")
|
||||
|
|
|
@ -46,7 +46,7 @@ class RoomMemberHandlerTestCase(unittest.TestCase):
|
|||
"get_room",
|
||||
"store_room",
|
||||
]),
|
||||
http_server=NonCallableMock(),
|
||||
resource_for_federation=NonCallableMock(),
|
||||
http_client=NonCallableMock(spec_set=[]),
|
||||
notifier=NonCallableMock(spec_set=["on_new_room_event"]),
|
||||
handlers=NonCallableMock(spec_set=[
|
||||
|
@ -317,7 +317,6 @@ class RoomCreationTest(unittest.TestCase):
|
|||
datastore=NonCallableMock(spec_set=[
|
||||
"store_room",
|
||||
]),
|
||||
http_server=NonCallableMock(),
|
||||
http_client=NonCallableMock(spec_set=[]),
|
||||
notifier=NonCallableMock(spec_set=["on_new_room_event"]),
|
||||
handlers=NonCallableMock(spec_set=[
|
||||
|
|
|
@ -52,7 +52,7 @@ class PresenceStateTestCase(unittest.TestCase):
|
|||
db_pool=None,
|
||||
http_client=None,
|
||||
resource_for_client=self.mock_server,
|
||||
http_server=self.mock_server,
|
||||
resource_for_federation=self.mock_server,
|
||||
)
|
||||
|
||||
def _get_user_by_token(token=None):
|
||||
|
@ -110,7 +110,7 @@ class PresenceListTestCase(unittest.TestCase):
|
|||
db_pool=None,
|
||||
http_client=None,
|
||||
resource_for_client=self.mock_server,
|
||||
http_server=self.mock_server,
|
||||
resource_for_federation=self.mock_server
|
||||
)
|
||||
|
||||
def _get_user_by_token(token=None):
|
||||
|
@ -185,8 +185,8 @@ class PresenceEventStreamTestCase(unittest.TestCase):
|
|||
hs = HomeServer("test",
|
||||
db_pool=None,
|
||||
http_client=None,
|
||||
http_server=self.mock_server,
|
||||
resource_for_client=self.mock_server,
|
||||
resource_for_federation=self.mock_server,
|
||||
datastore=Mock(spec=[
|
||||
"set_presence_state",
|
||||
"get_presence_list",
|
||||
|
|
|
@ -43,7 +43,6 @@ class ProfileTestCase(unittest.TestCase):
|
|||
hs = HomeServer("test",
|
||||
db_pool=None,
|
||||
http_client=None,
|
||||
http_server=self.mock_server,
|
||||
resource_for_client=self.mock_server,
|
||||
federation=Mock(),
|
||||
replication_layer=Mock(),
|
||||
|
|
Loading…
Reference in a new issue