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

Commit a330777

Browse files
committed
Alter - unit tests for the module API "create_room" method to align with new API
(of the unit under test) and to reduce the chances of false negatives during test execution.
1 parent 3b53122 commit a330777

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

tests/module_api/test_api.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from twisted.internet import defer
1717

1818
from synapse.api.constants import EduTypes, EventTypes
19-
from synapse.api.errors import SynapseError
2019
from synapse.events import EventBase
2120
from synapse.federation.units import Transaction
2221
from synapse.handlers.presence import UserPresenceState
@@ -639,27 +638,31 @@ def test_check_push_rules_actions(self) -> None:
639638

640639
def test_create_room(self) -> None:
641640
"""Test that modules can create a room."""
642-
# First test user existence verification.
641+
# First test user validation (i.e. user is local).
643642
self.get_failure(
644643
self.module_api.create_room(
645-
user_id="@user:test", config={}, ratelimit=False
644+
user_id=f"@user:{self.module_api.server_name}abc",
645+
config={},
646+
ratelimit=False,
646647
),
647-
SynapseError,
648+
RuntimeError,
648649
)
649650

650651
# Now do the happy path.
651652
user_id = self.register_user("user", "password")
653+
access_token = self.login(user_id, "password")
652654

653-
(result, _) = self.get_success(
655+
room_id, _ = self.get_success(
654656
self.module_api.create_room(user_id=user_id, config={}, ratelimit=False)
655657
)
656-
room_id = result["room_id"]
657658

658659
channel = self.make_request(
659660
"GET",
660-
f"/_matrix/client/r0/directory/list/room/{room_id}",
661+
f"/_matrix/client/v3/rooms/{room_id}/state/m.room.create",
662+
access_token=access_token,
661663
)
662664
self.assertEqual(channel.code, 200, channel.result)
665+
self.assertEqual(channel.json_body["creator"], user_id)
663666

664667

665668
class ModuleApiWorkerTestCase(BaseMultiWorkerStreamTestCase):

0 commit comments

Comments
 (0)