diff --git a/tests/handlers/test_federation.py b/tests/handlers/test_federation.py
index 5f11d5df11..21d63ab1f2 100644
--- a/tests/handlers/test_federation.py
+++ b/tests/handlers/test_federation.py
@@ -14,7 +14,7 @@
import logging
from typing import Collection, Optional, cast
from unittest import TestCase
-from unittest.mock import Mock, patch
+from unittest.mock import AsyncMock, Mock, patch
from twisted.internet.defer import Deferred
from twisted.test.proto_helpers import MemoryReactor
@@ -40,7 +40,7 @@ from synapse.util import Clock
from synapse.util.stringutils import random_string
from tests import unittest
-from tests.test_utils import event_injection, make_awaitable
+from tests.test_utils import event_injection
logger = logging.getLogger(__name__)
@@ -370,15 +370,15 @@ class FederationTestCase(unittest.FederatingHomeserverTestCase):
# We mock out the FederationClient.backfill method, to pretend that a remote
# server has returned our fake event.
- federation_client_backfill_mock = Mock(return_value=make_awaitable([event]))
- self.hs.get_federation_client().backfill = federation_client_backfill_mock # type: ignore[assignment]
+ federation_client_backfill_mock = AsyncMock(return_value=[event])
+ self.hs.get_federation_client().backfill = federation_client_backfill_mock # type: ignore[method-assign]
# We also mock the persist method with a side effect of itself. This allows us
# to track when it has been called while preserving its function.
persist_events_and_notify_mock = Mock(
side_effect=self.hs.get_federation_event_handler().persist_events_and_notify
)
- self.hs.get_federation_event_handler().persist_events_and_notify = ( # type: ignore[assignment]
+ self.hs.get_federation_event_handler().persist_events_and_notify = ( # type: ignore[method-assign]
persist_events_and_notify_mock
)
@@ -631,33 +631,29 @@ class PartialJoinTestCase(unittest.FederatingHomeserverTestCase):
},
RoomVersions.V10,
)
- mock_make_membership_event = Mock(
- return_value=make_awaitable(
- (
- "example.com",
- membership_event,
- RoomVersions.V10,
- )
+ mock_make_membership_event = AsyncMock(
+ return_value=(
+ "example.com",
+ membership_event,
+ RoomVersions.V10,
)
)
- mock_send_join = Mock(
- return_value=make_awaitable(
- SendJoinResult(
- membership_event,
- "example.com",
- state=[
- EVENT_CREATE,
- EVENT_CREATOR_MEMBERSHIP,
- EVENT_INVITATION_MEMBERSHIP,
- ],
- auth_chain=[
- EVENT_CREATE,
- EVENT_CREATOR_MEMBERSHIP,
- EVENT_INVITATION_MEMBERSHIP,
- ],
- partial_state=True,
- servers_in_room={"example.com"},
- )
+ mock_send_join = AsyncMock(
+ return_value=SendJoinResult(
+ membership_event,
+ "example.com",
+ state=[
+ EVENT_CREATE,
+ EVENT_CREATOR_MEMBERSHIP,
+ EVENT_INVITATION_MEMBERSHIP,
+ ],
+ auth_chain=[
+ EVENT_CREATE,
+ EVENT_CREATOR_MEMBERSHIP,
+ EVENT_INVITATION_MEMBERSHIP,
+ ],
+ partial_state=True,
+ servers_in_room={"example.com"},
)
)
|