mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-13 11:23:25 +01:00
Fix tests
This commit is contained in:
parent
bb99b1f550
commit
3e19beb941
6 changed files with 46 additions and 5 deletions
|
@ -122,6 +122,7 @@ class SlavedEventStoreTestCase(BaseSlavedStoreTestCase):
|
|||
|
||||
@defer.inlineCallbacks
|
||||
def test_invites(self):
|
||||
yield self.persist(type="m.room.create", key="", creator=USER_ID)
|
||||
yield self.check("get_invited_rooms_for_user", [USER_ID_2], [])
|
||||
event = yield self.persist(
|
||||
type="m.room.member", key=USER_ID_2, membership="invite"
|
||||
|
@ -134,7 +135,7 @@ class SlavedEventStoreTestCase(BaseSlavedStoreTestCase):
|
|||
|
||||
@defer.inlineCallbacks
|
||||
def test_push_actions_for_user(self):
|
||||
yield self.persist(type="m.room.create", creator=USER_ID)
|
||||
yield self.persist(type="m.room.create", key="", creator=USER_ID)
|
||||
yield self.persist(type="m.room.join", key=USER_ID, membership="join")
|
||||
yield self.persist(
|
||||
type="m.room.join", sender=USER_ID, key=USER_ID_2, membership="join"
|
||||
|
|
|
@ -22,7 +22,7 @@ from synapse.api.constants import EventTypes, Membership
|
|||
from synapse.types import RoomID, UserID
|
||||
|
||||
from tests import unittest
|
||||
from tests.utils import setup_test_homeserver
|
||||
from tests.utils import create_room, setup_test_homeserver
|
||||
|
||||
|
||||
class RedactionTestCase(unittest.TestCase):
|
||||
|
@ -43,6 +43,8 @@ class RedactionTestCase(unittest.TestCase):
|
|||
|
||||
self.room1 = RoomID.from_string("!abc123:test")
|
||||
|
||||
yield create_room(hs, self.room1.to_string(), self.u_alice.to_string())
|
||||
|
||||
self.depth = 1
|
||||
|
||||
@defer.inlineCallbacks
|
||||
|
|
|
@ -22,7 +22,7 @@ from synapse.api.constants import EventTypes, Membership
|
|||
from synapse.types import RoomID, UserID
|
||||
|
||||
from tests import unittest
|
||||
from tests.utils import setup_test_homeserver
|
||||
from tests.utils import create_room, setup_test_homeserver
|
||||
|
||||
|
||||
class RoomMemberStoreTestCase(unittest.TestCase):
|
||||
|
@ -47,6 +47,8 @@ class RoomMemberStoreTestCase(unittest.TestCase):
|
|||
|
||||
self.room = RoomID.from_string("!abc123:test")
|
||||
|
||||
yield create_room(hs, self.room.to_string(), self.u_alice.to_string())
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def inject_room_member(self, room, user, membership, replaces_state=None):
|
||||
builder = self.event_builder_factory.new({
|
||||
|
|
|
@ -18,7 +18,7 @@ from mock import Mock
|
|||
from twisted.internet import defer
|
||||
|
||||
from synapse.api.auth import Auth
|
||||
from synapse.api.constants import EventTypes, Membership
|
||||
from synapse.api.constants import EventTypes, Membership, RoomVersions
|
||||
from synapse.events import FrozenEvent
|
||||
from synapse.state import StateHandler, StateResolutionHandler
|
||||
|
||||
|
@ -108,6 +108,9 @@ class StateGroupStore(object):
|
|||
def register_event_id_state_group(self, event_id, state_group):
|
||||
self._event_to_state_group[event_id] = state_group
|
||||
|
||||
def get_room_version(self, room_id):
|
||||
return RoomVersions.V1
|
||||
|
||||
|
||||
class DictObj(dict):
|
||||
def __init__(self, **kwargs):
|
||||
|
@ -167,6 +170,7 @@ class StateTestCase(unittest.TestCase):
|
|||
"START": DictObj(
|
||||
type=EventTypes.Create,
|
||||
state_key="",
|
||||
content={},
|
||||
depth=1,
|
||||
),
|
||||
"A": DictObj(
|
||||
|
|
|
@ -21,7 +21,7 @@ from synapse.events import FrozenEvent
|
|||
from synapse.visibility import filter_events_for_server
|
||||
|
||||
import tests.unittest
|
||||
from tests.utils import setup_test_homeserver
|
||||
from tests.utils import create_room, setup_test_homeserver
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -36,6 +36,8 @@ class FilterEventsForServerTestCase(tests.unittest.TestCase):
|
|||
self.event_builder_factory = self.hs.get_event_builder_factory()
|
||||
self.store = self.hs.get_datastore()
|
||||
|
||||
yield create_room(self.hs, TEST_ROOM_ID, "@someone:ROOM")
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_filtering(self):
|
||||
#
|
||||
|
|
|
@ -21,6 +21,7 @@ from six.moves.urllib import parse as urlparse
|
|||
|
||||
from twisted.internet import defer, reactor
|
||||
|
||||
from synapse.api.constants import EventTypes
|
||||
from synapse.api.errors import CodeMessageException, cs_error
|
||||
from synapse.federation.transport import server
|
||||
from synapse.http.server import HttpServer
|
||||
|
@ -445,3 +446,32 @@ class DeferredMockCallable(object):
|
|||
"call(%s)" % _format_call(c[0], c[1]) for c in calls
|
||||
])
|
||||
)
|
||||
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def create_room(hs, room_id, creator_id):
|
||||
"""Creates and persist a creation event for the given room
|
||||
|
||||
Args:
|
||||
hs
|
||||
room_id (str)
|
||||
creator_id (str)
|
||||
"""
|
||||
|
||||
store = hs.get_datastore()
|
||||
event_builder_factory = hs.get_event_builder_factory()
|
||||
event_creation_handler = hs.get_event_creation_handler()
|
||||
|
||||
builder = event_builder_factory.new({
|
||||
"type": EventTypes.Create,
|
||||
"state_key": "",
|
||||
"sender": creator_id,
|
||||
"room_id": room_id,
|
||||
"content": {},
|
||||
})
|
||||
|
||||
event, context = yield event_creation_handler.create_new_client_event(
|
||||
builder
|
||||
)
|
||||
|
||||
yield store.persist_event(event, context)
|
||||
|
|
Loading…
Reference in a new issue