mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-05 04:04:59 -04:00
Add type hints to tests/rest/client
(#12084)
This commit is contained in:
parent
6c0b44a3d7
commit
1901cb1d4a
12 changed files with 198 additions and 138 deletions
|
@ -14,6 +14,8 @@
|
|||
|
||||
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.rest.client import (
|
||||
|
@ -23,13 +25,15 @@ from synapse.rest.client import (
|
|||
room,
|
||||
room_upgrade_rest_servlet,
|
||||
)
|
||||
from synapse.server import HomeServer
|
||||
from synapse.types import UserID
|
||||
from synapse.util import Clock
|
||||
|
||||
from tests import unittest
|
||||
|
||||
|
||||
class _ShadowBannedBase(unittest.HomeserverTestCase):
|
||||
def prepare(self, reactor, clock, homeserver):
|
||||
def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None:
|
||||
# Create two users, one of which is shadow-banned.
|
||||
self.banned_user_id = self.register_user("banned", "test")
|
||||
self.banned_access_token = self.login("banned", "test")
|
||||
|
@ -55,7 +59,7 @@ class RoomTestCase(_ShadowBannedBase):
|
|||
room_upgrade_rest_servlet.register_servlets,
|
||||
]
|
||||
|
||||
def test_invite(self):
|
||||
def test_invite(self) -> None:
|
||||
"""Invites from shadow-banned users don't actually get sent."""
|
||||
|
||||
# The create works fine.
|
||||
|
@ -77,7 +81,7 @@ class RoomTestCase(_ShadowBannedBase):
|
|||
)
|
||||
self.assertEqual(invited_rooms, [])
|
||||
|
||||
def test_invite_3pid(self):
|
||||
def test_invite_3pid(self) -> None:
|
||||
"""Ensure that a 3PID invite does not attempt to contact the identity server."""
|
||||
identity_handler = self.hs.get_identity_handler()
|
||||
identity_handler.lookup_3pid = Mock(
|
||||
|
@ -101,7 +105,7 @@ class RoomTestCase(_ShadowBannedBase):
|
|||
# This should have raised an error earlier, but double check this wasn't called.
|
||||
identity_handler.lookup_3pid.assert_not_called()
|
||||
|
||||
def test_create_room(self):
|
||||
def test_create_room(self) -> None:
|
||||
"""Invitations during a room creation should be discarded, but the room still gets created."""
|
||||
# The room creation is successful.
|
||||
channel = self.make_request(
|
||||
|
@ -126,7 +130,7 @@ class RoomTestCase(_ShadowBannedBase):
|
|||
users = self.get_success(self.store.get_users_in_room(room_id))
|
||||
self.assertCountEqual(users, ["@banned:test", "@otheruser:test"])
|
||||
|
||||
def test_message(self):
|
||||
def test_message(self) -> None:
|
||||
"""Messages from shadow-banned users don't actually get sent."""
|
||||
|
||||
room_id = self.helper.create_room_as(
|
||||
|
@ -151,7 +155,7 @@ class RoomTestCase(_ShadowBannedBase):
|
|||
)
|
||||
self.assertNotIn(event_id, latest_events)
|
||||
|
||||
def test_upgrade(self):
|
||||
def test_upgrade(self) -> None:
|
||||
"""A room upgrade should fail, but look like it succeeded."""
|
||||
|
||||
# The create works fine.
|
||||
|
@ -177,7 +181,7 @@ class RoomTestCase(_ShadowBannedBase):
|
|||
# The summary should be empty since the room doesn't exist.
|
||||
self.assertEqual(summary, {})
|
||||
|
||||
def test_typing(self):
|
||||
def test_typing(self) -> None:
|
||||
"""Typing notifications should not be propagated into the room."""
|
||||
# The create works fine.
|
||||
room_id = self.helper.create_room_as(
|
||||
|
@ -240,7 +244,7 @@ class ProfileTestCase(_ShadowBannedBase):
|
|||
room.register_servlets,
|
||||
]
|
||||
|
||||
def test_displayname(self):
|
||||
def test_displayname(self) -> None:
|
||||
"""Profile changes should succeed, but don't end up in a room."""
|
||||
original_display_name = "banned"
|
||||
new_display_name = "new name"
|
||||
|
@ -281,7 +285,7 @@ class ProfileTestCase(_ShadowBannedBase):
|
|||
event.content, {"membership": "join", "displayname": original_display_name}
|
||||
)
|
||||
|
||||
def test_room_displayname(self):
|
||||
def test_room_displayname(self) -> None:
|
||||
"""Changes to state events for a room should be processed, but not end up in the room."""
|
||||
original_display_name = "banned"
|
||||
new_display_name = "new name"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue