Remove redundant mocking

This commit is contained in:
Richard van der Hoff 2020-12-02 15:12:02 +00:00
parent 30fba62108
commit 90cf1eec44
5 changed files with 5 additions and 36 deletions

View File

@ -16,8 +16,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock
import jsonschema import jsonschema
from twisted.internet import defer from twisted.internet import defer
@ -28,7 +26,7 @@ from synapse.api.filtering import Filter
from synapse.events import make_event_from_dict from synapse.events import make_event_from_dict
from tests import unittest from tests import unittest
from tests.utils import DeferredMockCallable, MockHttpResource, setup_test_homeserver from tests.utils import setup_test_homeserver
user_localpart = "test_user" user_localpart = "test_user"
@ -42,21 +40,9 @@ def MockEvent(**kwargs):
class FilteringTestCase(unittest.TestCase): class FilteringTestCase(unittest.TestCase):
@defer.inlineCallbacks
def setUp(self): def setUp(self):
self.mock_federation_resource = MockHttpResource() hs = setup_test_homeserver(self.addCleanup)
self.mock_http_client = Mock(spec=[])
self.mock_http_client.put_json = DeferredMockCallable()
hs = yield setup_test_homeserver(
self.addCleanup,
federation_http_client=self.mock_http_client,
keyring=Mock(),
)
self.filtering = hs.get_filtering() self.filtering = hs.get_filtering()
self.datastore = hs.get_datastore() self.datastore = hs.get_datastore()
def test_errors_on_invalid_filters(self): def test_errors_on_invalid_filters(self):

View File

@ -42,8 +42,6 @@ class DirectoryTestCase(unittest.HomeserverTestCase):
self.mock_registry.register_query_handler = register_query_handler self.mock_registry.register_query_handler = register_query_handler
hs = self.setup_test_homeserver( hs = self.setup_test_homeserver(
federation_http_client=None,
resource_for_federation=Mock(),
federation_client=self.mock_federation, federation_client=self.mock_federation,
federation_registry=self.mock_registry, federation_registry=self.mock_registry,
) )

View File

@ -44,8 +44,6 @@ class ProfileTestCase(unittest.TestCase):
hs = yield setup_test_homeserver( hs = yield setup_test_homeserver(
self.addCleanup, self.addCleanup,
federation_http_client=None,
resource_for_federation=Mock(),
federation_client=self.mock_federation, federation_client=self.mock_federation,
federation_server=Mock(), federation_server=Mock(),
federation_registry=self.mock_registry, federation_registry=self.mock_registry,

View File

@ -14,9 +14,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock
from canonicaljson import json from canonicaljson import json
from twisted.internet import defer from twisted.internet import defer
@ -30,12 +27,10 @@ from tests.utils import create_room
class RedactionTestCase(unittest.HomeserverTestCase): class RedactionTestCase(unittest.HomeserverTestCase):
def make_homeserver(self, reactor, clock): def default_config(self):
config = self.default_config() config = super().default_config()
config["redaction_retention_period"] = "30d" config["redaction_retention_period"] = "30d"
return self.setup_test_homeserver( return config
resource_for_federation=Mock(), federation_http_client=None, config=config
)
def prepare(self, reactor, clock, hs): def prepare(self, reactor, clock, hs):
self.store = hs.get_datastore() self.store = hs.get_datastore()

View File

@ -14,8 +14,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from unittest.mock import Mock
from synapse.api.constants import Membership from synapse.api.constants import Membership
from synapse.rest.admin import register_servlets_for_client_rest_resource from synapse.rest.admin import register_servlets_for_client_rest_resource
from synapse.rest.client.v1 import login, room from synapse.rest.client.v1 import login, room
@ -34,12 +32,6 @@ class RoomMemberStoreTestCase(unittest.HomeserverTestCase):
room.register_servlets, room.register_servlets,
] ]
def make_homeserver(self, reactor, clock):
hs = self.setup_test_homeserver(
resource_for_federation=Mock(), federation_http_client=None
)
return hs
def prepare(self, reactor, clock, hs: TestHomeServer): def prepare(self, reactor, clock, hs: TestHomeServer):
# We can't test the RoomMemberStore on its own without the other event # We can't test the RoomMemberStore on its own without the other event