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

Commit

Permalink
Alter - unit tests for the module API "create_room" method to align w…
Browse files Browse the repository at this point in the history
…ith new API

(of the unit under test) and to reduce the chances of false negatives during
test execution.
  • Loading branch information
buffless-matt committed Aug 3, 2022
1 parent cdf27d5 commit 62fc9c8
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions tests/module_api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from twisted.internet import defer

from synapse.api.constants import EduTypes, EventTypes
from synapse.api.errors import SynapseError
from synapse.events import EventBase
from synapse.federation.units import Transaction
from synapse.handlers.presence import UserPresenceState
Expand Down Expand Up @@ -639,27 +638,31 @@ def test_check_push_rules_actions(self) -> None:

def test_create_room(self) -> None:
"""Test that modules can create a room."""
# First test user existence verification.
# First test user validation (i.e. user is local).
self.get_failure(
self.module_api.create_room(
user_id="@user:test", config={}, ratelimit=False
user_id=f"@user:{self.module_api.server_name}abc",
config={},
ratelimit=False,
),
SynapseError,
RuntimeError,
)

# Now do the happy path.
user_id = self.register_user("user", "password")
access_token = self.login(user_id, "password")

(result, _) = self.get_success(
room_id, _ = self.get_success(
self.module_api.create_room(user_id=user_id, config={}, ratelimit=False)
)
room_id = result["room_id"]

channel = self.make_request(
"GET",
f"/_matrix/client/r0/directory/list/room/{room_id}",
f"/_matrix/client/v3/rooms/{room_id}/state/m.room.create",
access_token=access_token,
)
self.assertEqual(channel.code, 200, channel.result)
self.assertEqual(channel.json_body["creator"], user_id)


class ModuleApiWorkerTestCase(BaseMultiWorkerStreamTestCase):
Expand Down

0 comments on commit 62fc9c8

Please sign in to comment.