2014-08-12 10:10:52 -04:00
|
|
|
# -*- coding: utf-8 -*-
|
2014-09-03 12:29:13 -04:00
|
|
|
# Copyright 2014 OpenMarket Ltd
|
2014-08-12 22:32:18 -04:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2014-08-12 10:10:52 -04:00
|
|
|
|
|
|
|
from twisted.internet import defer
|
2015-01-23 06:47:15 -05:00
|
|
|
from .. import unittest
|
2014-08-12 10:10:52 -04:00
|
|
|
|
2014-12-11 11:43:30 -05:00
|
|
|
from synapse.api.constants import EventTypes, Membership
|
2014-08-12 10:10:52 -04:00
|
|
|
from synapse.handlers.room import RoomMemberHandler, RoomCreationHandler
|
|
|
|
from synapse.handlers.profile import ProfileHandler
|
2015-01-23 06:47:15 -05:00
|
|
|
from synapse.types import UserID
|
2015-02-11 06:37:30 -05:00
|
|
|
from ..utils import setup_test_homeserver
|
2014-08-12 10:10:52 -04:00
|
|
|
|
|
|
|
from mock import Mock, NonCallableMock
|
|
|
|
|
|
|
|
|
|
|
|
class RoomMemberHandlerTestCase(unittest.TestCase):
|
|
|
|
|
2015-02-11 06:37:30 -05:00
|
|
|
@defer.inlineCallbacks
|
2014-08-12 10:10:52 -04:00
|
|
|
def setUp(self):
|
|
|
|
self.hostname = "red"
|
2015-02-11 06:37:30 -05:00
|
|
|
hs = yield setup_test_homeserver(
|
2014-08-12 10:10:52 -04:00
|
|
|
self.hostname,
|
2014-09-03 04:15:22 -04:00
|
|
|
ratelimiter=NonCallableMock(spec_set=[
|
|
|
|
"send_message",
|
|
|
|
]),
|
2014-08-12 10:10:52 -04:00
|
|
|
datastore=NonCallableMock(spec_set=[
|
2014-08-15 12:42:21 -04:00
|
|
|
"persist_event",
|
2014-08-12 10:10:52 -04:00
|
|
|
"get_room_member",
|
|
|
|
"get_room",
|
|
|
|
"store_room",
|
2014-12-12 09:32:39 -05:00
|
|
|
"get_latest_events_in_room",
|
2014-08-12 10:10:52 -04:00
|
|
|
]),
|
2014-08-14 05:18:54 -04:00
|
|
|
resource_for_federation=NonCallableMock(),
|
2014-08-12 10:10:52 -04:00
|
|
|
http_client=NonCallableMock(spec_set=[]),
|
|
|
|
notifier=NonCallableMock(spec_set=["on_new_room_event"]),
|
|
|
|
handlers=NonCallableMock(spec_set=[
|
|
|
|
"room_member_handler",
|
|
|
|
"profile_handler",
|
2014-08-26 14:49:42 -04:00
|
|
|
"federation_handler",
|
2014-08-12 10:10:52 -04:00
|
|
|
]),
|
2014-11-12 06:22:51 -05:00
|
|
|
auth=NonCallableMock(spec_set=[
|
|
|
|
"check",
|
|
|
|
"add_auth_events",
|
|
|
|
"check_host_in_room",
|
|
|
|
]),
|
2014-11-04 12:12:39 -05:00
|
|
|
state_handler=NonCallableMock(spec_set=[
|
2014-12-16 10:59:17 -05:00
|
|
|
"compute_event_context",
|
2014-11-12 06:22:51 -05:00
|
|
|
"get_current_state",
|
2014-11-04 12:12:39 -05:00
|
|
|
]),
|
2014-08-12 10:10:52 -04:00
|
|
|
)
|
|
|
|
|
2014-08-26 14:49:42 -04:00
|
|
|
self.federation = NonCallableMock(spec_set=[
|
|
|
|
"handle_new_event",
|
2014-11-10 09:58:33 -05:00
|
|
|
"send_invite",
|
2014-08-26 14:49:42 -04:00
|
|
|
"get_state_for_room",
|
|
|
|
])
|
|
|
|
|
2014-08-12 10:10:52 -04:00
|
|
|
self.datastore = hs.get_datastore()
|
|
|
|
self.handlers = hs.get_handlers()
|
|
|
|
self.notifier = hs.get_notifier()
|
|
|
|
self.state_handler = hs.get_state_handler()
|
|
|
|
self.distributor = hs.get_distributor()
|
2014-11-12 06:22:51 -05:00
|
|
|
self.auth = hs.get_auth()
|
2014-08-12 10:10:52 -04:00
|
|
|
self.hs = hs
|
|
|
|
|
2014-08-26 14:49:42 -04:00
|
|
|
self.handlers.federation_handler = self.federation
|
|
|
|
|
2014-08-20 11:04:01 -04:00
|
|
|
self.distributor.declare("collect_presencelike_data")
|
|
|
|
|
2014-08-12 10:10:52 -04:00
|
|
|
self.handlers.room_member_handler = RoomMemberHandler(self.hs)
|
|
|
|
self.handlers.profile_handler = ProfileHandler(self.hs)
|
|
|
|
self.room_member_handler = self.handlers.room_member_handler
|
|
|
|
|
2014-09-03 04:15:22 -04:00
|
|
|
self.ratelimiter = hs.get_ratelimiter()
|
|
|
|
self.ratelimiter.send_message.return_value = (True, 0)
|
2014-08-22 12:00:10 -04:00
|
|
|
|
2014-08-12 10:10:52 -04:00
|
|
|
@defer.inlineCallbacks
|
|
|
|
def test_invite(self):
|
|
|
|
room_id = "!foo:red"
|
|
|
|
user_id = "@bob:red"
|
|
|
|
target_user_id = "@red:blue"
|
|
|
|
content = {"membership": Membership.INVITE}
|
|
|
|
|
2014-12-12 09:32:39 -05:00
|
|
|
builder = self.hs.get_event_builder_factory().new({
|
2014-12-16 06:29:05 -05:00
|
|
|
"type": EventTypes.Member,
|
2014-12-12 09:32:39 -05:00
|
|
|
"sender": user_id,
|
|
|
|
"state_key": target_user_id,
|
|
|
|
"room_id": room_id,
|
|
|
|
"content": content,
|
|
|
|
})
|
|
|
|
|
|
|
|
self.datastore.get_latest_events_in_room.return_value = (
|
|
|
|
defer.succeed([])
|
2014-08-12 10:10:52 -04:00
|
|
|
)
|
|
|
|
|
2014-12-16 10:59:17 -05:00
|
|
|
def annotate(_):
|
|
|
|
ctx = Mock()
|
2014-12-12 09:32:39 -05:00
|
|
|
ctx.current_state = {
|
2014-12-16 06:29:05 -05:00
|
|
|
(EventTypes.Member, "@alice:green"): self._create_member(
|
2014-12-12 09:32:39 -05:00
|
|
|
user_id="@alice:green",
|
|
|
|
room_id=room_id,
|
|
|
|
),
|
2014-12-16 06:29:05 -05:00
|
|
|
(EventTypes.Member, "@bob:red"): self._create_member(
|
2014-12-12 09:32:39 -05:00
|
|
|
user_id="@bob:red",
|
|
|
|
room_id=room_id,
|
|
|
|
),
|
|
|
|
}
|
2014-12-16 10:59:17 -05:00
|
|
|
ctx.prev_state_events = []
|
2014-08-12 10:10:52 -04:00
|
|
|
|
2014-12-16 10:59:17 -05:00
|
|
|
return defer.succeed(ctx)
|
2014-08-12 10:10:52 -04:00
|
|
|
|
2014-12-16 10:59:17 -05:00
|
|
|
self.state_handler.compute_event_context.side_effect = annotate
|
2014-11-04 12:12:39 -05:00
|
|
|
|
2014-12-12 09:32:39 -05:00
|
|
|
def add_auth(_, ctx):
|
|
|
|
ctx.auth_events = ctx.current_state[
|
2014-12-16 06:29:05 -05:00
|
|
|
(EventTypes.Member, "@bob:red")
|
2014-12-12 09:32:39 -05:00
|
|
|
]
|
2014-11-10 09:58:33 -05:00
|
|
|
|
2014-12-12 09:32:39 -05:00
|
|
|
return defer.succeed(True)
|
|
|
|
self.auth.add_auth_events.side_effect = add_auth
|
2014-11-25 06:31:18 -05:00
|
|
|
|
2014-12-12 09:32:39 -05:00
|
|
|
def send_invite(domain, event):
|
|
|
|
return defer.succeed(event)
|
2014-08-12 10:10:52 -04:00
|
|
|
|
2014-12-12 09:32:39 -05:00
|
|
|
self.federation.send_invite.side_effect = send_invite
|
|
|
|
|
|
|
|
room_handler = self.room_member_handler
|
|
|
|
event, context = yield room_handler._create_new_client_event(
|
|
|
|
builder
|
2014-08-22 12:00:10 -04:00
|
|
|
)
|
2014-08-12 10:10:52 -04:00
|
|
|
|
2014-12-12 09:32:39 -05:00
|
|
|
yield room_handler.change_membership(event, context)
|
|
|
|
|
2014-12-16 10:59:17 -05:00
|
|
|
self.state_handler.compute_event_context.assert_called_once_with(
|
|
|
|
builder
|
2014-12-12 09:32:39 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
self.auth.add_auth_events.assert_called_once_with(
|
|
|
|
builder, context
|
|
|
|
)
|
|
|
|
|
|
|
|
self.federation.send_invite.assert_called_once_with(
|
|
|
|
"blue", event,
|
2014-08-12 10:10:52 -04:00
|
|
|
)
|
|
|
|
|
2014-08-15 12:42:21 -04:00
|
|
|
self.datastore.persist_event.assert_called_once_with(
|
2014-12-12 09:32:39 -05:00
|
|
|
event, context=context,
|
2014-08-12 10:10:52 -04:00
|
|
|
)
|
|
|
|
self.notifier.on_new_room_event.assert_called_once_with(
|
2015-01-23 06:47:15 -05:00
|
|
|
event, extra_users=[UserID.from_string(target_user_id)]
|
2014-08-22 12:00:10 -04:00
|
|
|
)
|
2014-08-12 10:10:52 -04:00
|
|
|
self.assertFalse(self.datastore.get_room.called)
|
|
|
|
self.assertFalse(self.datastore.store_room.called)
|
|
|
|
self.assertFalse(self.federation.get_state_for_room.called)
|
|
|
|
|
|
|
|
@defer.inlineCallbacks
|
|
|
|
def test_simple_join(self):
|
|
|
|
room_id = "!foo:red"
|
|
|
|
user_id = "@bob:red"
|
2015-01-23 06:47:15 -05:00
|
|
|
user = UserID.from_string(user_id)
|
2014-08-12 10:10:52 -04:00
|
|
|
|
2014-12-12 09:32:39 -05:00
|
|
|
join_signal_observer = Mock()
|
|
|
|
self.distributor.observe("user_joined_room", join_signal_observer)
|
2014-08-12 10:10:52 -04:00
|
|
|
|
2014-12-12 09:32:39 -05:00
|
|
|
builder = self.hs.get_event_builder_factory().new({
|
2014-12-16 06:29:05 -05:00
|
|
|
"type": EventTypes.Member,
|
2014-12-12 09:32:39 -05:00
|
|
|
"sender": user_id,
|
|
|
|
"state_key": user_id,
|
|
|
|
"room_id": room_id,
|
|
|
|
"content": {"membership": Membership.JOIN},
|
|
|
|
})
|
2014-08-12 10:10:52 -04:00
|
|
|
|
2014-12-12 09:32:39 -05:00
|
|
|
self.datastore.get_latest_events_in_room.return_value = (
|
|
|
|
defer.succeed([])
|
|
|
|
)
|
2014-08-12 10:10:52 -04:00
|
|
|
|
2014-12-16 10:59:17 -05:00
|
|
|
def annotate(_):
|
|
|
|
ctx = Mock()
|
2014-12-12 09:32:39 -05:00
|
|
|
ctx.current_state = {
|
2014-12-16 06:29:05 -05:00
|
|
|
(EventTypes.Member, "@bob:red"): self._create_member(
|
2014-12-12 09:32:39 -05:00
|
|
|
user_id="@bob:red",
|
|
|
|
room_id=room_id,
|
|
|
|
membership=Membership.INVITE
|
|
|
|
),
|
|
|
|
}
|
2014-12-16 10:59:17 -05:00
|
|
|
ctx.prev_state_events = []
|
2014-08-12 10:10:52 -04:00
|
|
|
|
2014-12-16 10:59:17 -05:00
|
|
|
return defer.succeed(ctx)
|
2014-08-12 10:10:52 -04:00
|
|
|
|
2014-12-16 10:59:17 -05:00
|
|
|
self.state_handler.compute_event_context.side_effect = annotate
|
2014-11-10 09:58:33 -05:00
|
|
|
|
2014-12-12 09:32:39 -05:00
|
|
|
def add_auth(_, ctx):
|
|
|
|
ctx.auth_events = ctx.current_state[
|
2014-12-16 06:29:05 -05:00
|
|
|
(EventTypes.Member, "@bob:red")
|
2014-12-12 09:32:39 -05:00
|
|
|
]
|
2014-11-25 06:31:18 -05:00
|
|
|
|
2014-12-12 09:32:39 -05:00
|
|
|
return defer.succeed(True)
|
|
|
|
self.auth.add_auth_events.side_effect = add_auth
|
|
|
|
|
|
|
|
room_handler = self.room_member_handler
|
|
|
|
event, context = yield room_handler._create_new_client_event(
|
|
|
|
builder
|
|
|
|
)
|
2014-11-25 06:31:18 -05:00
|
|
|
|
2014-08-12 10:10:52 -04:00
|
|
|
# Actual invocation
|
2014-12-12 09:32:39 -05:00
|
|
|
yield room_handler.change_membership(event, context)
|
2014-08-12 10:10:52 -04:00
|
|
|
|
2014-08-22 12:00:10 -04:00
|
|
|
self.federation.handle_new_event.assert_called_once_with(
|
2015-01-16 13:59:04 -05:00
|
|
|
event, destinations=set()
|
2014-08-12 10:10:52 -04:00
|
|
|
)
|
|
|
|
|
2014-08-15 12:42:21 -04:00
|
|
|
self.datastore.persist_event.assert_called_once_with(
|
2014-12-12 09:32:39 -05:00
|
|
|
event, context=context
|
2014-08-12 10:10:52 -04:00
|
|
|
)
|
|
|
|
self.notifier.on_new_room_event.assert_called_once_with(
|
2014-11-04 12:13:21 -05:00
|
|
|
event, extra_users=[user]
|
|
|
|
)
|
2014-08-12 10:10:52 -04:00
|
|
|
|
|
|
|
join_signal_observer.assert_called_with(
|
2014-11-04 12:13:21 -05:00
|
|
|
user=user, room_id=room_id
|
|
|
|
)
|
2014-08-12 10:10:52 -04:00
|
|
|
|
2014-12-12 09:32:39 -05:00
|
|
|
def _create_member(self, user_id, room_id, membership=Membership.JOIN):
|
|
|
|
builder = self.hs.get_event_builder_factory().new({
|
2014-12-16 06:29:05 -05:00
|
|
|
"type": EventTypes.Member,
|
2014-12-12 09:32:39 -05:00
|
|
|
"sender": user_id,
|
|
|
|
"state_key": user_id,
|
|
|
|
"room_id": room_id,
|
|
|
|
"content": {"membership": membership},
|
|
|
|
})
|
|
|
|
|
|
|
|
return builder.build()
|
2014-11-10 09:58:33 -05:00
|
|
|
|
2014-12-11 13:27:01 -05:00
|
|
|
@defer.inlineCallbacks
|
|
|
|
def test_simple_leave(self):
|
|
|
|
room_id = "!foo:red"
|
|
|
|
user_id = "@bob:red"
|
2015-01-23 06:47:15 -05:00
|
|
|
user = UserID.from_string(user_id)
|
2014-12-11 13:27:01 -05:00
|
|
|
|
2014-12-15 09:45:59 -05:00
|
|
|
builder = self.hs.get_event_builder_factory().new({
|
2014-12-16 06:29:05 -05:00
|
|
|
"type": EventTypes.Member,
|
2014-12-15 09:45:59 -05:00
|
|
|
"sender": user_id,
|
|
|
|
"state_key": user_id,
|
|
|
|
"room_id": room_id,
|
|
|
|
"content": {"membership": Membership.LEAVE},
|
|
|
|
})
|
|
|
|
|
|
|
|
self.datastore.get_latest_events_in_room.return_value = (
|
|
|
|
defer.succeed([])
|
2014-12-11 13:27:01 -05:00
|
|
|
)
|
|
|
|
|
2014-12-16 10:59:17 -05:00
|
|
|
def annotate(_):
|
|
|
|
ctx = Mock()
|
2014-12-15 09:45:59 -05:00
|
|
|
ctx.current_state = {
|
2014-12-16 06:29:05 -05:00
|
|
|
(EventTypes.Member, "@bob:red"): self._create_member(
|
2014-12-15 09:45:59 -05:00
|
|
|
user_id="@bob:red",
|
|
|
|
room_id=room_id,
|
2014-12-15 10:03:27 -05:00
|
|
|
membership=Membership.JOIN
|
2014-12-15 09:45:59 -05:00
|
|
|
),
|
|
|
|
}
|
2014-12-16 10:59:17 -05:00
|
|
|
ctx.prev_state_events = []
|
2014-12-15 09:45:59 -05:00
|
|
|
|
2014-12-16 10:59:17 -05:00
|
|
|
return defer.succeed(ctx)
|
2014-12-15 09:45:59 -05:00
|
|
|
|
2014-12-16 10:59:17 -05:00
|
|
|
self.state_handler.compute_event_context.side_effect = annotate
|
2014-12-15 09:45:59 -05:00
|
|
|
|
|
|
|
def add_auth(_, ctx):
|
|
|
|
ctx.auth_events = ctx.current_state[
|
2014-12-16 06:29:05 -05:00
|
|
|
(EventTypes.Member, "@bob:red")
|
2014-12-15 09:45:59 -05:00
|
|
|
]
|
2014-12-11 13:27:01 -05:00
|
|
|
|
2014-12-15 09:45:59 -05:00
|
|
|
return defer.succeed(True)
|
|
|
|
self.auth.add_auth_events.side_effect = add_auth
|
2014-12-11 13:27:01 -05:00
|
|
|
|
2014-12-15 09:45:59 -05:00
|
|
|
room_handler = self.room_member_handler
|
|
|
|
event, context = yield room_handler._create_new_client_event(
|
|
|
|
builder
|
|
|
|
)
|
2014-12-11 13:27:01 -05:00
|
|
|
|
|
|
|
leave_signal_observer = Mock()
|
|
|
|
self.distributor.observe("user_left_room", leave_signal_observer)
|
|
|
|
|
|
|
|
# Actual invocation
|
2014-12-15 09:45:59 -05:00
|
|
|
yield room_handler.change_membership(event, context)
|
2014-12-11 13:27:01 -05:00
|
|
|
|
2014-12-15 10:03:27 -05:00
|
|
|
self.federation.handle_new_event.assert_called_once_with(
|
2015-01-16 13:59:04 -05:00
|
|
|
event, destinations=set(['red'])
|
2014-12-15 10:03:27 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
self.datastore.persist_event.assert_called_once_with(
|
|
|
|
event, context=context
|
|
|
|
)
|
|
|
|
self.notifier.on_new_room_event.assert_called_once_with(
|
|
|
|
event, extra_users=[user]
|
|
|
|
)
|
|
|
|
|
2014-12-11 13:27:01 -05:00
|
|
|
leave_signal_observer.assert_called_with(
|
|
|
|
user=user, room_id=room_id
|
|
|
|
)
|
|
|
|
|
2014-08-12 10:10:52 -04:00
|
|
|
|
|
|
|
class RoomCreationTest(unittest.TestCase):
|
|
|
|
|
2015-02-11 06:37:30 -05:00
|
|
|
@defer.inlineCallbacks
|
2014-08-12 10:10:52 -04:00
|
|
|
def setUp(self):
|
|
|
|
self.hostname = "red"
|
2014-11-04 12:12:39 -05:00
|
|
|
|
2015-02-11 06:37:30 -05:00
|
|
|
hs = yield setup_test_homeserver(
|
2014-08-12 10:10:52 -04:00
|
|
|
self.hostname,
|
|
|
|
datastore=NonCallableMock(spec_set=[
|
|
|
|
"store_room",
|
2014-08-27 10:11:51 -04:00
|
|
|
"snapshot_room",
|
2014-09-01 14:57:17 -04:00
|
|
|
"persist_event",
|
|
|
|
"get_joined_hosts_for_room",
|
2014-08-12 10:10:52 -04:00
|
|
|
]),
|
|
|
|
http_client=NonCallableMock(spec_set=[]),
|
|
|
|
notifier=NonCallableMock(spec_set=["on_new_room_event"]),
|
|
|
|
handlers=NonCallableMock(spec_set=[
|
|
|
|
"room_creation_handler",
|
2014-12-11 11:43:30 -05:00
|
|
|
"message_handler",
|
2014-08-12 10:10:52 -04:00
|
|
|
]),
|
2014-11-10 09:58:33 -05:00
|
|
|
auth=NonCallableMock(spec_set=["check", "add_auth_events"]),
|
2014-09-03 04:15:22 -04:00
|
|
|
ratelimiter=NonCallableMock(spec_set=[
|
|
|
|
"send_message",
|
|
|
|
]),
|
2014-08-12 10:10:52 -04:00
|
|
|
)
|
|
|
|
|
2014-08-26 14:49:42 -04:00
|
|
|
self.federation = NonCallableMock(spec_set=[
|
|
|
|
"handle_new_event",
|
|
|
|
])
|
|
|
|
|
2014-08-12 10:10:52 -04:00
|
|
|
self.handlers = hs.get_handlers()
|
2014-08-26 14:49:42 -04:00
|
|
|
|
2014-12-11 11:43:30 -05:00
|
|
|
self.handlers.room_creation_handler = RoomCreationHandler(hs)
|
2014-08-12 10:10:52 -04:00
|
|
|
self.room_creation_handler = self.handlers.room_creation_handler
|
|
|
|
|
2014-12-11 11:43:30 -05:00
|
|
|
self.message_handler = self.handlers.message_handler
|
2014-09-01 14:57:17 -04:00
|
|
|
|
2014-09-03 04:15:22 -04:00
|
|
|
self.ratelimiter = hs.get_ratelimiter()
|
|
|
|
self.ratelimiter.send_message.return_value = (True, 0)
|
|
|
|
|
2014-08-12 10:10:52 -04:00
|
|
|
@defer.inlineCallbacks
|
|
|
|
def test_room_creation(self):
|
|
|
|
user_id = "@foo:red"
|
|
|
|
room_id = "!bobs_room:red"
|
|
|
|
config = {"visibility": "private"}
|
|
|
|
|
|
|
|
yield self.room_creation_handler.create_room(
|
|
|
|
user_id=user_id,
|
|
|
|
room_id=room_id,
|
|
|
|
config=config,
|
|
|
|
)
|
|
|
|
|
2014-12-15 12:01:12 -05:00
|
|
|
self.assertTrue(self.message_handler.create_and_send_event.called)
|
2014-12-11 11:43:30 -05:00
|
|
|
|
|
|
|
event_dicts = [
|
2014-12-15 12:01:12 -05:00
|
|
|
e[0][0]
|
|
|
|
for e in self.message_handler.create_and_send_event.call_args_list
|
2014-12-11 11:43:30 -05:00
|
|
|
]
|
2014-08-12 10:10:52 -04:00
|
|
|
|
2014-12-11 11:43:30 -05:00
|
|
|
self.assertTrue(len(event_dicts) > 3)
|
2014-08-12 10:10:52 -04:00
|
|
|
|
2014-12-11 11:43:30 -05:00
|
|
|
self.assertDictContainsSubset(
|
|
|
|
{
|
|
|
|
"type": EventTypes.Create,
|
|
|
|
"sender": user_id,
|
|
|
|
"room_id": room_id,
|
|
|
|
},
|
|
|
|
event_dicts[0]
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(user_id, event_dicts[0]["content"]["creator"])
|
2014-08-12 10:10:52 -04:00
|
|
|
|
2014-12-11 11:43:30 -05:00
|
|
|
self.assertDictContainsSubset(
|
|
|
|
{
|
|
|
|
"type": EventTypes.Member,
|
|
|
|
"sender": user_id,
|
|
|
|
"room_id": room_id,
|
|
|
|
"state_key": user_id,
|
|
|
|
},
|
|
|
|
event_dicts[1]
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
Membership.JOIN,
|
|
|
|
event_dicts[1]["content"]["membership"]
|
|
|
|
)
|