Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Back out some changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Jun 4, 2020
1 parent 14a0af5 commit c145c81
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 63 deletions.
14 changes: 2 additions & 12 deletions tests/handlers/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
# limitations under the License.


from mock import Mock, patch
from mock import Mock, NonCallableMock

from twisted.internet import defer

import synapse.types
from synapse.api.errors import AuthError, SynapseError
from synapse.api.ratelimiting import Ratelimiter
from synapse.handlers.profile import MasterProfileHandler
from synapse.types import UserID

Expand Down Expand Up @@ -56,16 +55,7 @@ def register_query_handler(query_type, handler):
federation_client=self.mock_federation,
federation_server=Mock(),
federation_registry=self.mock_registry,
)

# Patch Ratelimiter to allow all requests
patch.object(
Ratelimiter,
"can_do_action",
new_callable=lambda *args, **kwargs: (True, 0.0),
)
patch.object(
Ratelimiter, "ratelimit", new_callable=lambda *args, **kwargs: None
ratelimiter=NonCallableMock(spec_set=["can_do_action"]),
)

self.store = hs.get_datastore()
Expand Down
17 changes: 4 additions & 13 deletions tests/replication/slave/storage/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from mock import Mock, patch

from synapse.api.ratelimiting import Ratelimiter
from mock import Mock, NonCallableMock

from tests.replication._base import BaseStreamTestCase


class BaseSlavedStoreTestCase(BaseStreamTestCase):
def make_homeserver(self, reactor, clock):

hs = self.setup_test_homeserver(federation_client=Mock(),)

# Patch Ratelimiter to allow all requests
patch.object(
Ratelimiter,
"can_do_action",
new_callable=lambda *args, **kwargs: (True, 0.0),
)
patch.object(
Ratelimiter, "ratelimit", new_callable=lambda *args, **kwargs: None
hs = self.setup_test_homeserver(
federation_client=Mock(),
ratelimiter=NonCallableMock(spec_set=["can_do_action"]),
)

return hs
Expand Down
15 changes: 3 additions & 12 deletions tests/rest/client/v1/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@

""" Tests REST events for /events paths."""

from mock import Mock, patch
from mock import Mock, NonCallableMock

import synapse.rest.admin
from synapse.api.ratelimiting import Ratelimiter
from synapse.rest.client.v1 import events, login, room

from tests import unittest
Expand All @@ -41,16 +40,8 @@ def make_homeserver(self, reactor, clock):
config["enable_registration"] = True
config["auto_join_rooms"] = []

hs = self.setup_test_homeserver(config=config,)

# Patch Ratelimiter to allow all requests
patch.object(
Ratelimiter,
"can_do_action",
new_callable=lambda *args, **kwargs: (True, 0.0),
)
patch.object(
Ratelimiter, "ratelimit", new_callable=lambda *args, **kwargs: None
hs = self.setup_test_homeserver(
config=config, ratelimiter=NonCallableMock(spec_set=["can_do_action"])
)

hs.get_handlers().federation_handler = Mock()
Expand Down
18 changes: 5 additions & 13 deletions tests/rest/client/v1/test_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@

import json

from mock import Mock, patch
from mock import Mock, NonCallableMock
from six.moves.urllib import parse as urlparse

from twisted.internet import defer

import synapse.rest.admin
from synapse.api.constants import EventContentFields, EventTypes, Membership
from synapse.api.ratelimiting import Ratelimiter
from synapse.handlers.pagination import PurgeStatus
from synapse.rest.client.v1 import directory, login, profile, room
from synapse.rest.client.v2_alpha import account
Expand All @@ -47,17 +46,10 @@ class RoomBase(unittest.HomeserverTestCase):
def make_homeserver(self, reactor, clock):

self.hs = self.setup_test_homeserver(
"red", http_client=None, federation_client=Mock(),
)

# Patch Ratelimiter to allow all requests
patch.object(
Ratelimiter,
"can_do_action",
new_callable=lambda *args, **kwargs: (True, 0.0),
)
patch.object(
Ratelimiter, "ratelimit", new_callable=lambda *args, **kwargs: None
"red",
http_client=None,
federation_client=Mock(),
ratelimiter=NonCallableMock(spec_set=["can_do_action"]),
)

self.hs.get_federation_handler = Mock(return_value=Mock())
Expand Down
18 changes: 5 additions & 13 deletions tests/rest/client/v1/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

"""Tests REST events for /rooms paths."""

from mock import Mock, patch
from mock import Mock, NonCallableMock

from twisted.internet import defer

from synapse.api.ratelimiting import Ratelimiter
from synapse.rest.client.v1 import room
from synapse.types import UserID

Expand All @@ -40,17 +39,10 @@ class RoomTypingTestCase(unittest.HomeserverTestCase):
def make_homeserver(self, reactor, clock):

hs = self.setup_test_homeserver(
"red", http_client=None, federation_client=Mock(),
)

# Patch Ratelimiter to allow all requests
patch.object(
Ratelimiter,
"can_do_action",
new_callable=lambda *args, **kwargs: (True, 0.0),
)
patch.object(
Ratelimiter, "ratelimit", new_callable=lambda *args, **kwargs: None
"red",
http_client=None,
federation_client=Mock(),
ratelimiter=NonCallableMock(spec_set=["can_do_action"]),
)

self.event_source = hs.get_event_sources().sources["typing"]
Expand Down

0 comments on commit c145c81

Please sign in to comment.