summaryrefslogtreecommitdiff
path: root/tests/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'tests/handlers')
-rw-r--r--tests/handlers/test_appservice.py16
-rw-r--r--tests/handlers/test_directory.py3
-rw-r--r--tests/handlers/test_federation.py19
-rw-r--r--tests/handlers/test_federation_event.py15
-rw-r--r--tests/handlers/test_message.py14
-rw-r--r--tests/handlers/test_receipts.py94
-rw-r--r--tests/handlers/test_room_summary.py20
-rw-r--r--tests/handlers/test_sync.py1
-rw-r--r--tests/handlers/test_typing.py41
-rw-r--r--tests/handlers/test_user_directory.py3
10 files changed, 118 insertions, 108 deletions
diff --git a/tests/handlers/test_appservice.py b/tests/handlers/test_appservice.py
index 5b0cd1ab..d96d5aa1 100644
--- a/tests/handlers/test_appservice.py
+++ b/tests/handlers/test_appservice.py
@@ -22,6 +22,7 @@ from twisted.test.proto_helpers import MemoryReactor
import synapse.rest.admin
import synapse.storage
+from synapse.api.constants import EduTypes
from synapse.appservice import (
ApplicationService,
TransactionOneTimeKeyCounts,
@@ -434,16 +435,6 @@ class ApplicationServicesHandlerSendEventsTestCase(unittest.HomeserverTestCase):
},
)
- # "Complete" a transaction.
- # All this really does for us is make an entry in the application_services_state
- # database table, which tracks the current stream_token per stream ID per AS.
- self.get_success(
- self.hs.get_datastores().main.complete_appservice_txn(
- 0,
- interested_appservice,
- )
- )
-
# Now, pretend that we receive a large burst of read receipts (300 total) that
# all come in at once.
for i in range(300):
@@ -486,7 +477,7 @@ class ApplicationServicesHandlerSendEventsTestCase(unittest.HomeserverTestCase):
# Check that the ephemeral event is a read receipt with the expected structure
latest_read_receipt = all_ephemeral_events[-1]
- self.assertEqual(latest_read_receipt["type"], "m.receipt")
+ self.assertEqual(latest_read_receipt["type"], EduTypes.RECEIPT)
event_id = list(latest_read_receipt["content"].keys())[0]
self.assertEqual(
@@ -706,7 +697,6 @@ class ApplicationServicesHandlerSendEventsTestCase(unittest.HomeserverTestCase):
# Create an application service
appservice = ApplicationService(
token=random_string(10),
- hostname="example.com",
id=random_string(10),
sender="@as:example.com",
rate_limited=False,
@@ -785,7 +775,6 @@ class ApplicationServicesHandlerDeviceListsTestCase(unittest.HomeserverTestCase)
# Create an appservice that is interested in "local_user"
appservice = ApplicationService(
token=random_string(10),
- hostname="example.com",
id=random_string(10),
sender="@as:example.com",
rate_limited=False,
@@ -852,7 +841,6 @@ class ApplicationServicesHandlerOtkCountsTestCase(unittest.HomeserverTestCase):
self._service_token = "VERYSECRET"
self._service = ApplicationService(
self._service_token,
- "as1.invalid",
"as1",
"@as.sender:test",
namespaces={
diff --git a/tests/handlers/test_directory.py b/tests/handlers/test_directory.py
index 11ad4422..53d49ca8 100644
--- a/tests/handlers/test_directory.py
+++ b/tests/handlers/test_directory.py
@@ -298,6 +298,7 @@ class CanonicalAliasTestCase(unittest.HomeserverTestCase):
self.store = hs.get_datastores().main
self.handler = hs.get_directory_handler()
self.state_handler = hs.get_state_handler()
+ self._storage_controllers = hs.get_storage_controllers()
# Create user
self.admin_user = self.register_user("admin", "pass", admin=True)
@@ -335,7 +336,7 @@ class CanonicalAliasTestCase(unittest.HomeserverTestCase):
def _get_canonical_alias(self):
"""Get the canonical alias state of the room."""
return self.get_success(
- self.state_handler.get_current_state(
+ self._storage_controllers.state.get_current_state_event(
self.room_id, EventTypes.CanonicalAlias, ""
)
)
diff --git a/tests/handlers/test_federation.py b/tests/handlers/test_federation.py
index 060ba5f5..e0eda545 100644
--- a/tests/handlers/test_federation.py
+++ b/tests/handlers/test_federation.py
@@ -50,7 +50,7 @@ class FederationTestCase(unittest.FederatingHomeserverTestCase):
hs = self.setup_test_homeserver(federation_http_client=None)
self.handler = hs.get_federation_handler()
self.store = hs.get_datastores().main
- self.state_store = hs.get_storage().state
+ self.state_storage_controller = hs.get_storage_controllers().state
self._event_auth_handler = hs.get_event_auth_handler()
return hs
@@ -237,7 +237,9 @@ class FederationTestCase(unittest.FederatingHomeserverTestCase):
)
current_state = self.get_success(
self.store.get_events_as_list(
- (self.get_success(self.store.get_current_state_ids(room_id))).values()
+ (
+ self.get_success(self.store.get_partial_current_state_ids(room_id))
+ ).values()
)
)
@@ -276,7 +278,11 @@ class FederationTestCase(unittest.FederatingHomeserverTestCase):
# federation handler wanting to backfill the fake event.
self.get_success(
federation_event_handler._process_received_pdu(
- self.OTHER_SERVER_NAME, event, state=current_state
+ self.OTHER_SERVER_NAME,
+ event,
+ state_ids={
+ (e.type, e.state_key): e.event_id for e in current_state
+ },
)
)
@@ -332,8 +338,11 @@ class FederationTestCase(unittest.FederatingHomeserverTestCase):
most_recent_prev_event_depth,
) = self.get_success(self.store.get_max_depth_of(prev_event_ids))
# mapping from (type, state_key) -> state_event_id
+ assert most_recent_prev_event_id is not None
prev_state_map = self.get_success(
- self.state_store.get_state_ids_for_event(most_recent_prev_event_id)
+ self.state_storage_controller.get_state_ids_for_event(
+ most_recent_prev_event_id
+ )
)
# List of state event ID's
prev_state_ids = list(prev_state_map.values())
@@ -505,7 +514,7 @@ class FederationTestCase(unittest.FederatingHomeserverTestCase):
self.get_success(d)
# sanity-check: the room should show that the new user is a member
- r = self.get_success(self.store.get_current_state_ids(room_id))
+ r = self.get_success(self.store.get_partial_current_state_ids(room_id))
self.assertEqual(r[(EventTypes.Member, other_user)], join_event.event_id)
return join_event
diff --git a/tests/handlers/test_federation_event.py b/tests/handlers/test_federation_event.py
index 489ba577..1a36c25c 100644
--- a/tests/handlers/test_federation_event.py
+++ b/tests/handlers/test_federation_event.py
@@ -70,7 +70,7 @@ class FederationEventHandlerTests(unittest.FederatingHomeserverTestCase):
) -> None:
OTHER_USER = f"@user:{self.OTHER_SERVER_NAME}"
main_store = self.hs.get_datastores().main
- state_storage = self.hs.get_storage().state
+ state_storage_controller = self.hs.get_storage_controllers().state
# create the room
user_id = self.register_user("kermit", "test")
@@ -91,7 +91,9 @@ class FederationEventHandlerTests(unittest.FederatingHomeserverTestCase):
event_injection.inject_member_event(self.hs, room_id, OTHER_USER, "join")
)
- initial_state_map = self.get_success(main_store.get_current_state_ids(room_id))
+ initial_state_map = self.get_success(
+ main_store.get_partial_current_state_ids(room_id)
+ )
auth_event_ids = [
initial_state_map[("m.room.create", "")],
@@ -146,9 +148,12 @@ class FederationEventHandlerTests(unittest.FederatingHomeserverTestCase):
)
if prev_exists_as_outlier:
prev_event.internal_metadata.outlier = True
- persistence = self.hs.get_storage().persistence
+ persistence = self.hs.get_storage_controllers().persistence
self.get_success(
- persistence.persist_event(prev_event, EventContext.for_outlier())
+ persistence.persist_event(
+ prev_event,
+ EventContext.for_outlier(self.hs.get_storage_controllers()),
+ )
)
else:
@@ -214,7 +219,7 @@ class FederationEventHandlerTests(unittest.FederatingHomeserverTestCase):
# check that the state at that event is as expected
state = self.get_success(
- state_storage.get_state_ids_for_event(pulled_event.event_id)
+ state_storage_controller.get_state_ids_for_event(pulled_event.event_id)
)
expected_state = {
(e.type, e.state_key): e.event_id for e in state_at_prev_event
diff --git a/tests/handlers/test_message.py b/tests/handlers/test_message.py
index f4f7ab48..44da96c7 100644
--- a/tests/handlers/test_message.py
+++ b/tests/handlers/test_message.py
@@ -37,7 +37,9 @@ class EventCreationTestCase(unittest.HomeserverTestCase):
def prepare(self, reactor, clock, hs):
self.handler = self.hs.get_event_creation_handler()
- self.persist_event_storage = self.hs.get_storage().persistence
+ self._persist_event_storage_controller = (
+ self.hs.get_storage_controllers().persistence
+ )
self.user_id = self.register_user("tester", "foobar")
self.access_token = self.login("tester", "foobar")
@@ -65,7 +67,9 @@ class EventCreationTestCase(unittest.HomeserverTestCase):
)
)
self.get_success(
- self.persist_event_storage.persist_event(memberEvent, memberEventContext)
+ self._persist_event_storage_controller.persist_event(
+ memberEvent, memberEventContext
+ )
)
return memberEvent, memberEventContext
@@ -129,7 +133,7 @@ class EventCreationTestCase(unittest.HomeserverTestCase):
self.assertNotEqual(event1.event_id, event3.event_id)
ret_event3, event_pos3, _ = self.get_success(
- self.persist_event_storage.persist_event(event3, context)
+ self._persist_event_storage_controller.persist_event(event3, context)
)
# Assert that the returned values match those from the initial event
@@ -143,7 +147,7 @@ class EventCreationTestCase(unittest.HomeserverTestCase):
self.assertNotEqual(event1.event_id, event3.event_id)
events, _ = self.get_success(
- self.persist_event_storage.persist_events([(event3, context)])
+ self._persist_event_storage_controller.persist_events([(event3, context)])
)
ret_event4 = events[0]
@@ -166,7 +170,7 @@ class EventCreationTestCase(unittest.HomeserverTestCase):
self.assertNotEqual(event1.event_id, event2.event_id)
events, _ = self.get_success(
- self.persist_event_storage.persist_events(
+ self._persist_event_storage_controller.persist_events(
[(event1, context1), (event2, context2)]
)
)
diff --git a/tests/handlers/test_receipts.py b/tests/handlers/test_receipts.py
index 0482a1ea..a95868b5 100644
--- a/tests/handlers/test_receipts.py
+++ b/tests/handlers/test_receipts.py
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
+from copy import deepcopy
from typing import List
-from synapse.api.constants import ReceiptTypes
+from synapse.api.constants import EduTypes, ReceiptTypes
from synapse.types import JsonDict
from tests import unittest
@@ -39,7 +39,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
}
},
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
- "type": "m.receipt",
+ "type": EduTypes.RECEIPT,
}
],
[],
@@ -64,7 +64,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
},
},
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
- "type": "m.receipt",
+ "type": EduTypes.RECEIPT,
}
],
[
@@ -79,7 +79,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
}
},
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
- "type": "m.receipt",
+ "type": EduTypes.RECEIPT,
}
],
)
@@ -105,7 +105,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
},
},
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
- "type": "m.receipt",
+ "type": EduTypes.RECEIPT,
}
],
[
@@ -120,43 +120,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
}
},
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
- "type": "m.receipt",
- }
- ],
- )
-
- def test_handles_missing_content_of_m_read(self):
- self._test_filters_private(
- [
- {
- "content": {
- "$14356419ggffg114394fHBLK:matrix.org": {ReceiptTypes.READ: {}},
- "$1435641916114394fHBLK:matrix.org": {
- ReceiptTypes.READ: {
- "@user:jki.re": {
- "ts": 1436451550453,
- }
- }
- },
- },
- "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
- "type": "m.receipt",
- }
- ],
- [
- {
- "content": {
- "$14356419ggffg114394fHBLK:matrix.org": {ReceiptTypes.READ: {}},
- "$1435641916114394fHBLK:matrix.org": {
- ReceiptTypes.READ: {
- "@user:jki.re": {
- "ts": 1436451550453,
- }
- }
- },
- },
- "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
- "type": "m.receipt",
+ "type": EduTypes.RECEIPT,
}
],
)
@@ -176,7 +140,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
},
},
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
- "type": "m.receipt",
+ "type": EduTypes.RECEIPT,
}
],
[
@@ -191,7 +155,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
},
},
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
- "type": "m.receipt",
+ "type": EduTypes.RECEIPT,
}
],
)
@@ -210,7 +174,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
},
},
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
- "type": "m.receipt",
+ "type": EduTypes.RECEIPT,
},
{
"content": {
@@ -223,7 +187,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
},
},
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
- "type": "m.receipt",
+ "type": EduTypes.RECEIPT,
},
],
[
@@ -238,7 +202,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
}
},
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
- "type": "m.receipt",
+ "type": EduTypes.RECEIPT,
}
],
)
@@ -260,7 +224,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
},
},
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
- "type": "m.receipt",
+ "type": EduTypes.RECEIPT,
},
],
[
@@ -273,7 +237,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
},
},
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
- "type": "m.receipt",
+ "type": EduTypes.RECEIPT,
},
],
)
@@ -302,7 +266,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
},
},
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
- "type": "m.receipt",
+ "type": EduTypes.RECEIPT,
}
],
[
@@ -327,14 +291,38 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
}
},
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
- "type": "m.receipt",
+ "type": EduTypes.RECEIPT,
}
],
)
+ def test_we_do_not_mutate(self):
+ """Ensure the input values are not modified."""
+ events = [
+ {
+ "content": {
+ "$1435641916114394fHBLK:matrix.org": {
+ ReceiptTypes.READ_PRIVATE: {
+ "@rikj:jki.re": {
+ "ts": 1436451550453,
+ }
+ }
+ }
+ },
+ "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
+ "type": EduTypes.RECEIPT,
+ }
+ ]
+ original_events = deepcopy(events)
+ self._test_filters_private(events, [])
+ # Since the events are fed in from a cache they should not be modified.
+ self.assertEqual(events, original_events)
+
def _test_filters_private(
self, events: List[JsonDict], expected_output: List[JsonDict]
):
"""Tests that the _filter_out_private returns the expected output"""
- filtered_events = self.event_source.filter_out_private(events, "@me:server.org")
+ filtered_events = self.event_source.filter_out_private_receipts(
+ events, "@me:server.org"
+ )
self.assertEqual(filtered_events, expected_output)
diff --git a/tests/handlers/test_room_summary.py b/tests/handlers/test_room_summary.py
index e74eb717..05466556 100644
--- a/tests/handlers/test_room_summary.py
+++ b/tests/handlers/test_room_summary.py
@@ -179,7 +179,7 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
result_children_ids.append(
[
(cs["room_id"], cs["state_key"])
- for cs in result_room.get("children_state")
+ for cs in result_room["children_state"]
]
)
@@ -772,7 +772,7 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
{
"room_id": public_room,
"world_readable": False,
- "join_rules": JoinRules.PUBLIC,
+ "join_rule": JoinRules.PUBLIC,
},
),
(
@@ -780,7 +780,7 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
{
"room_id": knock_room,
"world_readable": False,
- "join_rules": JoinRules.KNOCK,
+ "join_rule": JoinRules.KNOCK,
},
),
(
@@ -788,7 +788,7 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
{
"room_id": not_invited_room,
"world_readable": False,
- "join_rules": JoinRules.INVITE,
+ "join_rule": JoinRules.INVITE,
},
),
(
@@ -796,7 +796,7 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
{
"room_id": invited_room,
"world_readable": False,
- "join_rules": JoinRules.INVITE,
+ "join_rule": JoinRules.INVITE,
},
),
(
@@ -804,7 +804,7 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
{
"room_id": restricted_room,
"world_readable": False,
- "join_rules": JoinRules.RESTRICTED,
+ "join_rule": JoinRules.RESTRICTED,
"allowed_room_ids": [],
},
),
@@ -813,7 +813,7 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
{
"room_id": restricted_accessible_room,
"world_readable": False,
- "join_rules": JoinRules.RESTRICTED,
+ "join_rule": JoinRules.RESTRICTED,
"allowed_room_ids": [self.room],
},
),
@@ -822,7 +822,7 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
{
"room_id": world_readable_room,
"world_readable": True,
- "join_rules": JoinRules.INVITE,
+ "join_rule": JoinRules.INVITE,
},
),
(
@@ -830,7 +830,7 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
{
"room_id": joined_room,
"world_readable": False,
- "join_rules": JoinRules.INVITE,
+ "join_rule": JoinRules.INVITE,
},
),
)
@@ -911,7 +911,7 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
{
"room_id": fed_room,
"world_readable": False,
- "join_rules": JoinRules.INVITE,
+ "join_rule": JoinRules.INVITE,
},
)
diff --git a/tests/handlers/test_sync.py b/tests/handlers/test_sync.py
index 865b8b7e..db3302a4 100644
--- a/tests/handlers/test_sync.py
+++ b/tests/handlers/test_sync.py
@@ -160,6 +160,7 @@ class SyncTestCase(tests.unittest.HomeserverTestCase):
# Blow away caches (supported room versions can only change due to a restart).
self.store.get_rooms_for_user_with_stream_ordering.invalidate_all()
self.store._get_event_cache.clear()
+ self.store._event_ref.clear()
# The rooms should be excluded from the sync response.
# Get a new request key.
diff --git a/tests/handlers/test_typing.py b/tests/handlers/test_typing.py
index 5f2e26a5..7af13331 100644
--- a/tests/handlers/test_typing.py
+++ b/tests/handlers/test_typing.py
@@ -21,6 +21,7 @@ from twisted.internet import defer
from twisted.test.proto_helpers import MemoryReactor
from twisted.web.resource import Resource
+from synapse.api.constants import EduTypes
from synapse.api.errors import AuthError
from synapse.federation.transport.server import TransportLayerServer
from synapse.server import HomeServer
@@ -128,10 +129,12 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
hs.get_event_auth_handler().check_host_in_room = check_host_in_room
- def get_joined_hosts_for_room(room_id: str):
+ async def get_current_hosts_in_room(room_id: str):
return {member.domain for member in self.room_members}
- self.datastore.get_joined_hosts_for_room = get_joined_hosts_for_room
+ hs.get_storage_controllers().state.get_current_hosts_in_room = (
+ get_current_hosts_in_room
+ )
async def get_users_in_room(room_id: str):
return {str(u) for u in self.room_members}
@@ -145,7 +148,7 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
)
)
- self.datastore.get_current_state_deltas = Mock(return_value=(0, None))
+ self.datastore.get_partial_current_state_deltas = Mock(return_value=(0, None))
self.datastore.get_to_device_stream_token = lambda: 0
self.datastore.get_new_device_msgs_for_remote = (
@@ -184,7 +187,7 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
events[0],
[
{
- "type": "m.typing",
+ "type": EduTypes.TYPING,
"room_id": ROOM_ID,
"content": {"user_ids": [U_APPLE.to_string()]},
}
@@ -209,7 +212,7 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
"farm",
path="/_matrix/federation/v1/send/1000000",
data=_expect_edu_transaction(
- "m.typing",
+ EduTypes.TYPING,
content={
"room_id": ROOM_ID,
"user_id": U_APPLE.to_string(),
@@ -231,7 +234,7 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
"PUT",
"/_matrix/federation/v1/send/1000000",
_make_edu_transaction_json(
- "m.typing",
+ EduTypes.TYPING,
content={
"room_id": ROOM_ID,
"user_id": U_ONION.to_string(),
@@ -254,7 +257,7 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
events[0],
[
{
- "type": "m.typing",
+ "type": EduTypes.TYPING,
"room_id": ROOM_ID,
"content": {"user_ids": [U_ONION.to_string()]},
}
@@ -270,7 +273,7 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
"PUT",
"/_matrix/federation/v1/send/1000000",
_make_edu_transaction_json(
- "m.typing",
+ EduTypes.TYPING,
content={
"room_id": OTHER_ROOM_ID,
"user_id": U_ONION.to_string(),
@@ -324,7 +327,7 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
"farm",
path="/_matrix/federation/v1/send/1000000",
data=_expect_edu_transaction(
- "m.typing",
+ EduTypes.TYPING,
content={
"room_id": ROOM_ID,
"user_id": U_APPLE.to_string(),
@@ -345,7 +348,13 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
)
self.assertEqual(
events[0],
- [{"type": "m.typing", "room_id": ROOM_ID, "content": {"user_ids": []}}],
+ [
+ {
+ "type": EduTypes.TYPING,
+ "room_id": ROOM_ID,
+ "content": {"user_ids": []},
+ }
+ ],
)
def test_typing_timeout(self) -> None:
@@ -379,7 +388,7 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
events[0],
[
{
- "type": "m.typing",
+ "type": EduTypes.TYPING,
"room_id": ROOM_ID,
"content": {"user_ids": [U_APPLE.to_string()]},
}
@@ -402,7 +411,13 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
)
self.assertEqual(
events[0],
- [{"type": "m.typing", "room_id": ROOM_ID, "content": {"user_ids": []}}],
+ [
+ {
+ "type": EduTypes.TYPING,
+ "room_id": ROOM_ID,
+ "content": {"user_ids": []},
+ }
+ ],
)
# SYN-230 - see if we can still set after timeout
@@ -433,7 +448,7 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
events[0],
[
{
- "type": "m.typing",
+ "type": EduTypes.TYPING,
"room_id": ROOM_ID,
"content": {"user_ids": [U_APPLE.to_string()]},
}
diff --git a/tests/handlers/test_user_directory.py b/tests/handlers/test_user_directory.py
index 4d658d29..9e39cd97 100644
--- a/tests/handlers/test_user_directory.py
+++ b/tests/handlers/test_user_directory.py
@@ -60,7 +60,6 @@ class UserDirectoryTestCase(unittest.HomeserverTestCase):
self.appservice = ApplicationService(
token="i_am_an_app_service",
- hostname="test",
id="1234",
namespaces={"users": [{"regex": r"@as_user.*", "exclusive": True}]},
# Note: this user does not match the regex above, so that tests
@@ -954,7 +953,7 @@ class UserDirectoryTestCase(unittest.HomeserverTestCase):
)
self.get_success(
- self.hs.get_storage().persistence.persist_event(event, context)
+ self.hs.get_storage_controllers().persistence.persist_event(event, context)
)
def test_local_user_leaving_room_remains_in_user_directory(self) -> None: