summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2022-05-27 07:14:36 -0400
committerGitHub <noreply@github.com>2022-05-27 07:14:36 -0400
commitc52abc1cfdd9e5480cdb4a03d626fe61cacc6573 (patch)
tree0859f49a5d1e69ce8c844ba9d785c67a2a747854 /tests
parentRemove federation client code for groups. (#12563) (diff)
downloadsynapse-c52abc1cfdd9e5480cdb4a03d626fe61cacc6573.tar.xz
Additional constants for EDU types. (#12884)
Instead of hard-coding strings in many places.
Diffstat (limited to 'tests')
-rw-r--r--tests/api/test_filtering.py6
-rw-r--r--tests/events/test_presence_router.py2
-rw-r--r--tests/federation/test_federation_sender.py26
-rw-r--r--tests/federation/transport/test_server.py4
-rw-r--r--tests/handlers/test_appservice.py3
-rw-r--r--tests/handlers/test_receipts.py32
-rw-r--r--tests/handlers/test_typing.py33
-rw-r--r--tests/module_api/test_api.py2
-rw-r--r--tests/rest/client/test_events.py3
-rw-r--r--tests/rest/client/test_rooms.py3
-rw-r--r--tests/rest/client/test_sendtodevice.py5
-rw-r--r--tests/rest/client/test_shadow_banned.py4
-rw-r--r--tests/rest/client/test_sync.py3
-rw-r--r--tests/rest/client/test_typing.py3
-rw-r--r--tests/storage/test_devices.py7
15 files changed, 81 insertions, 55 deletions
diff --git a/tests/api/test_filtering.py b/tests/api/test_filtering.py
index 985d6e397d..a269c477fb 100644
--- a/tests/api/test_filtering.py
+++ b/tests/api/test_filtering.py
@@ -20,7 +20,7 @@ from unittest.mock import patch
 import jsonschema
 from frozendict import frozendict
 
-from synapse.api.constants import EventContentFields
+from synapse.api.constants import EduTypes, EventContentFields
 from synapse.api.errors import SynapseError
 from synapse.api.filtering import Filter
 from synapse.events import make_event_from_dict
@@ -85,13 +85,13 @@ class FilteringTestCase(unittest.HomeserverTestCase):
                         "org.matrix.not_labels": ["#work"],
                     },
                     "ephemeral": {
-                        "types": ["m.receipt", "m.typing"],
+                        "types": [EduTypes.RECEIPT, EduTypes.TYPING],
                         "not_rooms": ["!726s6s6q:example.com"],
                         "not_senders": ["@spam:example.com"],
                     },
                 },
                 "presence": {
-                    "types": ["m.presence"],
+                    "types": [EduTypes.PRESENCE],
                     "not_senders": ["@alice:example.com"],
                 },
                 "event_format": "client",
diff --git a/tests/events/test_presence_router.py b/tests/events/test_presence_router.py
index 3deb14c308..ffc3012a86 100644
--- a/tests/events/test_presence_router.py
+++ b/tests/events/test_presence_router.py
@@ -439,7 +439,7 @@ class PresenceRouterTestCase(FederatingHomeserverTestCase):
 
             for edu in edus:
                 # Make sure we're only checking presence-type EDUs
-                if edu["edu_type"] != EduTypes.Presence:
+                if edu["edu_type"] != EduTypes.PRESENCE:
                     continue
 
                 # EDUs can contain multiple presence updates
diff --git a/tests/federation/test_federation_sender.py b/tests/federation/test_federation_sender.py
index 6b26353d5e..b5be727fe4 100644
--- a/tests/federation/test_federation_sender.py
+++ b/tests/federation/test_federation_sender.py
@@ -19,7 +19,7 @@ from signedjson.types import BaseKey, SigningKey
 
 from twisted.internet import defer
 
-from synapse.api.constants import RoomEncryptionAlgorithms
+from synapse.api.constants import EduTypes, RoomEncryptionAlgorithms
 from synapse.rest import admin
 from synapse.rest.client import login
 from synapse.types import JsonDict, ReadReceipt
@@ -63,7 +63,7 @@ class FederationSenderReceiptsTestCases(HomeserverTestCase):
             data["edus"],
             [
                 {
-                    "edu_type": "m.receipt",
+                    "edu_type": EduTypes.RECEIPT,
                     "content": {
                         "room_id": {
                             "m.read": {
@@ -103,7 +103,7 @@ class FederationSenderReceiptsTestCases(HomeserverTestCase):
             data["edus"],
             [
                 {
-                    "edu_type": "m.receipt",
+                    "edu_type": EduTypes.RECEIPT,
                     "content": {
                         "room_id": {
                             "m.read": {
@@ -138,7 +138,7 @@ class FederationSenderReceiptsTestCases(HomeserverTestCase):
             data["edus"],
             [
                 {
-                    "edu_type": "m.receipt",
+                    "edu_type": EduTypes.RECEIPT,
                     "content": {
                         "room_id": {
                             "m.read": {
@@ -322,8 +322,10 @@ class FederationSenderDevicesTestCases(HomeserverTestCase):
 
         # expect signing key update edu
         self.assertEqual(len(self.edus), 2)
-        self.assertEqual(self.edus.pop(0)["edu_type"], "m.signing_key_update")
-        self.assertEqual(self.edus.pop(0)["edu_type"], "org.matrix.signing_key_update")
+        self.assertEqual(self.edus.pop(0)["edu_type"], EduTypes.SIGNING_KEY_UPDATE)
+        self.assertEqual(
+            self.edus.pop(0)["edu_type"], EduTypes.UNSTABLE_SIGNING_KEY_UPDATE
+        )
 
         # sign the devices
         d1_json = build_device_dict(u1, "D1", device1_signing_key)
@@ -348,7 +350,7 @@ class FederationSenderDevicesTestCases(HomeserverTestCase):
         self.assertEqual(len(self.edus), 2)
         stream_id = None  # FIXME: there is a discontinuity in the stream IDs: see #7142
         for edu in self.edus:
-            self.assertEqual(edu["edu_type"], "m.device_list_update")
+            self.assertEqual(edu["edu_type"], EduTypes.DEVICE_LIST_UPDATE)
             c = edu["content"]
             if stream_id is not None:
                 self.assertEqual(c["prev_id"], [stream_id])
@@ -388,7 +390,7 @@ class FederationSenderDevicesTestCases(HomeserverTestCase):
         # expect three edus, in an unknown order
         self.assertEqual(len(self.edus), 3)
         for edu in self.edus:
-            self.assertEqual(edu["edu_type"], "m.device_list_update")
+            self.assertEqual(edu["edu_type"], EduTypes.DEVICE_LIST_UPDATE)
             c = edu["content"]
             self.assertGreaterEqual(
                 c.items(),
@@ -435,7 +437,7 @@ class FederationSenderDevicesTestCases(HomeserverTestCase):
         self.assertEqual(len(self.edus), 3)
         stream_id = None
         for edu in self.edus:
-            self.assertEqual(edu["edu_type"], "m.device_list_update")
+            self.assertEqual(edu["edu_type"], EduTypes.DEVICE_LIST_UPDATE)
             c = edu["content"]
             self.assertEqual(c["prev_id"], [stream_id] if stream_id is not None else [])
             if stream_id is not None:
@@ -487,7 +489,7 @@ class FederationSenderDevicesTestCases(HomeserverTestCase):
         # there should be a single update for this user.
         self.assertEqual(len(self.edus), 1)
         edu = self.edus.pop(0)
-        self.assertEqual(edu["edu_type"], "m.device_list_update")
+        self.assertEqual(edu["edu_type"], EduTypes.DEVICE_LIST_UPDATE)
         c = edu["content"]
 
         # synapse uses an empty prev_id list to indicate "needs a full resync".
@@ -544,7 +546,7 @@ class FederationSenderDevicesTestCases(HomeserverTestCase):
         # ... and we should get a single update for this user.
         self.assertEqual(len(self.edus), 1)
         edu = self.edus.pop(0)
-        self.assertEqual(edu["edu_type"], "m.device_list_update")
+        self.assertEqual(edu["edu_type"], EduTypes.DEVICE_LIST_UPDATE)
         c = edu["content"]
 
         # synapse uses an empty prev_id list to indicate "needs a full resync".
@@ -560,7 +562,7 @@ class FederationSenderDevicesTestCases(HomeserverTestCase):
         """Check that the given EDU is an update for the given device
         Returns the stream_id.
         """
-        self.assertEqual(edu["edu_type"], "m.device_list_update")
+        self.assertEqual(edu["edu_type"], EduTypes.DEVICE_LIST_UPDATE)
         content = edu["content"]
 
         expected = {
diff --git a/tests/federation/transport/test_server.py b/tests/federation/transport/test_server.py
index 5f001c33b0..cfd550a04b 100644
--- a/tests/federation/transport/test_server.py
+++ b/tests/federation/transport/test_server.py
@@ -12,6 +12,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from synapse.api.constants import EduTypes
+
 from tests import unittest
 from tests.unittest import DEBUG, override_config
 
@@ -50,7 +52,7 @@ class RoomDirectoryFederationTests(unittest.FederatingHomeserverTestCase):
             "/_matrix/federation/v1/send/txn_id_1234/",
             content={
                 "edus": [
-                    {"edu_type": "m.device_list_update", "content": {"foo": "bar"}}
+                    {"edu_type": EduTypes.DEVICE_LIST_UPDATE, "content": {"foo": "bar"}}
                 ],
                 "pdus": [],
             },
diff --git a/tests/handlers/test_appservice.py b/tests/handlers/test_appservice.py
index 53e7a5d81b..0e100c404d 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,
@@ -476,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(
diff --git a/tests/handlers/test_receipts.py b/tests/handlers/test_receipts.py
index 78807cdcfc..a95868b5c0 100644
--- a/tests/handlers/test_receipts.py
+++ b/tests/handlers/test_receipts.py
@@ -15,7 +15,7 @@
 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,7 +120,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
                         }
                     },
                     "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
-                    "type": "m.receipt",
+                    "type": EduTypes.RECEIPT,
                 }
             ],
         )
@@ -140,7 +140,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
                         },
                     },
                     "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
-                    "type": "m.receipt",
+                    "type": EduTypes.RECEIPT,
                 }
             ],
             [
@@ -155,7 +155,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
                         },
                     },
                     "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
-                    "type": "m.receipt",
+                    "type": EduTypes.RECEIPT,
                 }
             ],
         )
@@ -174,7 +174,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
                         },
                     },
                     "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
-                    "type": "m.receipt",
+                    "type": EduTypes.RECEIPT,
                 },
                 {
                     "content": {
@@ -187,7 +187,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
                         },
                     },
                     "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
-                    "type": "m.receipt",
+                    "type": EduTypes.RECEIPT,
                 },
             ],
             [
@@ -202,7 +202,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
                         }
                     },
                     "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
-                    "type": "m.receipt",
+                    "type": EduTypes.RECEIPT,
                 }
             ],
         )
@@ -224,7 +224,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
                         },
                     },
                     "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
-                    "type": "m.receipt",
+                    "type": EduTypes.RECEIPT,
                 },
             ],
             [
@@ -237,7 +237,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
                         },
                     },
                     "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
-                    "type": "m.receipt",
+                    "type": EduTypes.RECEIPT,
                 },
             ],
         )
@@ -266,7 +266,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
                         },
                     },
                     "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
-                    "type": "m.receipt",
+                    "type": EduTypes.RECEIPT,
                 }
             ],
             [
@@ -291,7 +291,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
                         }
                     },
                     "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
-                    "type": "m.receipt",
+                    "type": EduTypes.RECEIPT,
                 }
             ],
         )
@@ -310,7 +310,7 @@ class ReceiptsTestCase(unittest.HomeserverTestCase):
                     }
                 },
                 "room_id": "!jEsUZKDJdhlrceRyVU:example.org",
-                "type": "m.receipt",
+                "type": EduTypes.RECEIPT,
             }
         ]
         original_events = deepcopy(events)
diff --git a/tests/handlers/test_typing.py b/tests/handlers/test_typing.py
index 5f2e26a5fc..057256cecd 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
@@ -184,7 +185,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 +210,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 +232,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 +255,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 +271,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 +325,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 +346,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 +386,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 +409,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 +446,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/module_api/test_api.py b/tests/module_api/test_api.py
index 8bc84aaaca..169e29b590 100644
--- a/tests/module_api/test_api.py
+++ b/tests/module_api/test_api.py
@@ -399,7 +399,7 @@ class ModuleApiTestCase(HomeserverTestCase):
 
             for edu in edus:
                 # Make sure we're only checking presence-type EDUs
-                if edu["edu_type"] != EduTypes.Presence:
+                if edu["edu_type"] != EduTypes.PRESENCE:
                     continue
 
                 # EDUs can contain multiple presence updates
diff --git a/tests/rest/client/test_events.py b/tests/rest/client/test_events.py
index 1b1392fa2f..a9b7db9db2 100644
--- a/tests/rest/client/test_events.py
+++ b/tests/rest/client/test_events.py
@@ -19,6 +19,7 @@ from unittest.mock import Mock
 from twisted.test.proto_helpers import MemoryReactor
 
 import synapse.rest.admin
+from synapse.api.constants import EduTypes
 from synapse.rest.client import events, login, room
 from synapse.server import HomeServer
 from synapse.util import Clock
@@ -103,7 +104,7 @@ class EventStreamPermissionsTestCase(unittest.HomeserverTestCase):
                     c
                     for c in channel.json_body["chunk"]
                     if not (
-                        c.get("type") == "m.presence"
+                        c.get("type") == EduTypes.PRESENCE
                         and c["content"].get("user_id") == self.user_id
                     )
                 ]
diff --git a/tests/rest/client/test_rooms.py b/tests/rest/client/test_rooms.py
index d0197aca94..f523d89b8f 100644
--- a/tests/rest/client/test_rooms.py
+++ b/tests/rest/client/test_rooms.py
@@ -26,6 +26,7 @@ from twisted.test.proto_helpers import MemoryReactor
 
 import synapse.rest.admin
 from synapse.api.constants import (
+    EduTypes,
     EventContentFields,
     EventTypes,
     Membership,
@@ -1412,7 +1413,7 @@ class RoomInitialSyncTestCase(RoomBase):
             e["content"]["user_id"]: e for e in channel.json_body["presence"]
         }
         self.assertTrue(self.user_id in presence_by_user)
-        self.assertEqual("m.presence", presence_by_user[self.user_id]["type"])
+        self.assertEqual(EduTypes.PRESENCE, presence_by_user[self.user_id]["type"])
 
 
 class RoomMessageListTestCase(RoomBase):
diff --git a/tests/rest/client/test_sendtodevice.py b/tests/rest/client/test_sendtodevice.py
index c3942889e1..6435800fa1 100644
--- a/tests/rest/client/test_sendtodevice.py
+++ b/tests/rest/client/test_sendtodevice.py
@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from synapse.api.constants import EduTypes
 from synapse.rest import admin
 from synapse.rest.client import login, sendtodevice, sync
 
@@ -139,7 +140,7 @@ class SendToDeviceTestCase(HomeserverTestCase):
         for i in range(3):
             self.get_success(
                 federation_registry.on_edu(
-                    "m.direct_to_device",
+                    EduTypes.DIRECT_TO_DEVICE,
                     "remote_server",
                     {
                         "sender": "@user:remote_server",
@@ -172,7 +173,7 @@ class SendToDeviceTestCase(HomeserverTestCase):
         # and we can send more messages
         self.get_success(
             federation_registry.on_edu(
-                "m.direct_to_device",
+                EduTypes.DIRECT_TO_DEVICE,
                 "remote_server",
                 {
                     "sender": "@user:remote_server",
diff --git a/tests/rest/client/test_shadow_banned.py b/tests/rest/client/test_shadow_banned.py
index ae5ada3be7..d9bd8c4a28 100644
--- a/tests/rest/client/test_shadow_banned.py
+++ b/tests/rest/client/test_shadow_banned.py
@@ -17,7 +17,7 @@ from unittest.mock import Mock, patch
 from twisted.test.proto_helpers import MemoryReactor
 
 import synapse.rest.admin
-from synapse.api.constants import EventTypes
+from synapse.api.constants import EduTypes, EventTypes
 from synapse.rest.client import (
     directory,
     login,
@@ -226,7 +226,7 @@ class RoomTestCase(_ShadowBannedBase):
             events[0],
             [
                 {
-                    "type": "m.typing",
+                    "type": EduTypes.TYPING,
                     "room_id": room_id,
                     "content": {"user_ids": [self.other_user_id]},
                 }
diff --git a/tests/rest/client/test_sync.py b/tests/rest/client/test_sync.py
index 74b6560cbc..e3efd1f1b0 100644
--- a/tests/rest/client/test_sync.py
+++ b/tests/rest/client/test_sync.py
@@ -22,6 +22,7 @@ from twisted.test.proto_helpers import MemoryReactor
 
 import synapse.rest.admin
 from synapse.api.constants import (
+    EduTypes,
     EventContentFields,
     EventTypes,
     ReceiptTypes,
@@ -504,7 +505,7 @@ class ReadReceiptsTestCase(unittest.HomeserverTestCase):
 
         # Checks if event is a read receipt
         def is_read_receipt(event: JsonDict) -> bool:
-            return event["type"] == "m.receipt"
+            return event["type"] == EduTypes.RECEIPT
 
         # Sync
         channel = self.make_request(
diff --git a/tests/rest/client/test_typing.py b/tests/rest/client/test_typing.py
index d6da510773..61b66d7685 100644
--- a/tests/rest/client/test_typing.py
+++ b/tests/rest/client/test_typing.py
@@ -17,6 +17,7 @@
 
 from twisted.test.proto_helpers import MemoryReactor
 
+from synapse.api.constants import EduTypes
 from synapse.rest.client import room
 from synapse.server import HomeServer
 from synapse.types import UserID
@@ -67,7 +68,7 @@ class RoomTypingTestCase(unittest.HomeserverTestCase):
             events[0],
             [
                 {
-                    "type": "m.typing",
+                    "type": EduTypes.TYPING,
                     "room_id": self.room_id,
                     "content": {"user_ids": [self.user_id]},
                 }
diff --git a/tests/storage/test_devices.py b/tests/storage/test_devices.py
index bbf079b25b..f37505b6cf 100644
--- a/tests/storage/test_devices.py
+++ b/tests/storage/test_devices.py
@@ -13,6 +13,7 @@
 # limitations under the License.
 
 import synapse.api.errors
+from synapse.api.constants import EduTypes
 
 from tests.unittest import HomeserverTestCase
 
@@ -266,10 +267,12 @@ class DeviceStoreTestCase(HomeserverTestCase):
         # (This is a temporary arrangement for backwards compatibility!)
         self.assertEqual(len(device_updates), 2, device_updates)
         self.assertEqual(
-            device_updates[0][0], "m.signing_key_update", device_updates[0]
+            device_updates[0][0], EduTypes.SIGNING_KEY_UPDATE, device_updates[0]
         )
         self.assertEqual(
-            device_updates[1][0], "org.matrix.signing_key_update", device_updates[1]
+            device_updates[1][0],
+            EduTypes.UNSTABLE_SIGNING_KEY_UPDATE,
+            device_updates[1],
         )
 
         # Check there are no more device updates left.