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

Commit

Permalink
Don't instansiate Requester directly (#8614)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston authored Oct 22, 2020
1 parent b28aaeb commit 2ac908f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions changelog.d/8614.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't instansiate Requester directly.
6 changes: 3 additions & 3 deletions tests/storage/test_cleanup_extrems.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from synapse.api.constants import EventTypes
from synapse.rest.client.v1 import login, room
from synapse.storage import prepare_database
from synapse.types import Requester, UserID
from synapse.types import UserID, create_requester

from tests.unittest import HomeserverTestCase

Expand All @@ -38,7 +38,7 @@ def prepare(self, reactor, clock, homeserver):

# Create a test user and room
self.user = UserID("alice", "test")
self.requester = Requester(self.user, None, False, False, None, None)
self.requester = create_requester(self.user)
info, _ = self.get_success(self.room_creator.create_room(self.requester, {}))
self.room_id = info["room_id"]

Expand Down Expand Up @@ -260,7 +260,7 @@ def prepare(self, reactor, clock, homeserver):
# Create a test user and room
self.user = UserID.from_string(self.register_user("user1", "password"))
self.token1 = self.login("user1", "password")
self.requester = Requester(self.user, None, False, False, None, None)
self.requester = create_requester(self.user)
info, _ = self.get_success(self.room_creator.create_room(self.requester, {}))
self.room_id = info["room_id"]
self.event_creator = homeserver.get_event_creation_handler()
Expand Down
4 changes: 2 additions & 2 deletions tests/storage/test_event_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

from synapse.metrics import REGISTRY, generate_latest
from synapse.types import Requester, UserID
from synapse.types import UserID, create_requester

from tests.unittest import HomeserverTestCase

Expand All @@ -27,7 +27,7 @@ def test_exposed_to_prometheus(self):
room_creator = self.hs.get_room_creation_handler()

user = UserID("alice", "test")
requester = Requester(user, None, False, False, None, None)
requester = create_requester(user)

# Real events, forward extremities
events = [(3, 2), (6, 2), (4, 6)]
Expand Down
4 changes: 2 additions & 2 deletions tests/storage/test_roommember.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from synapse.api.constants import Membership
from synapse.rest.admin import register_servlets_for_client_rest_resource
from synapse.rest.client.v1 import login, room
from synapse.types import Requester, UserID
from synapse.types import UserID, create_requester

from tests import unittest
from tests.test_utils import event_injection
Expand Down Expand Up @@ -187,7 +187,7 @@ def test_can_rerun_update(self):

# Now let's create a room, which will insert a membership
user = UserID("alice", "test")
requester = Requester(user, None, False, False, None, None)
requester = create_requester(user)
self.get_success(self.room_creator.create_room(requester, {}))

# Register the background update to run again.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from synapse.api.errors import FederationError
from synapse.events import make_event_from_dict
from synapse.logging.context import LoggingContext
from synapse.types import Requester, UserID
from synapse.types import UserID, create_requester
from synapse.util import Clock
from synapse.util.retryutils import NotRetryingDestination

Expand All @@ -43,7 +43,7 @@ def setUp(self):
)

user_id = UserID("us", "test")
our_user = Requester(user_id, None, False, False, None, None)
our_user = create_requester(user_id)
room_creator = self.homeserver.get_room_creation_handler()
self.room_id = self.get_success(
room_creator.create_room(
Expand Down
4 changes: 2 additions & 2 deletions tests/unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
set_current_context,
)
from synapse.server import HomeServer
from synapse.types import Requester, UserID, create_requester
from synapse.types import UserID, create_requester
from synapse.util.ratelimitutils import FederationRateLimiter

from tests.server import (
Expand Down Expand Up @@ -627,7 +627,7 @@ def create_and_send_event(
"""
event_creator = self.hs.get_event_creation_handler()
secrets = self.hs.get_secrets()
requester = Requester(user, None, False, False, None, None)
requester = create_requester(user)

event, context = self.get_success(
event_creator.create_event(
Expand Down

0 comments on commit 2ac908f

Please sign in to comment.