mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Fix up the various presence-related tests so that if they're not skipped, they still PASS
This commit is contained in:
parent
407c86c013
commit
d027e859cd
@ -92,10 +92,7 @@ class PresenceStateTestCase(unittest.TestCase):
|
||||
self.datastore.is_presence_visible = is_presence_visible
|
||||
|
||||
# Mock the RoomMemberHandler
|
||||
room_member_handler = Mock(spec=[
|
||||
"get_rooms_for_user",
|
||||
"get_room_members",
|
||||
])
|
||||
room_member_handler = Mock(spec=[])
|
||||
hs.handlers.room_member_handler = room_member_handler
|
||||
logging.getLogger().debug("Mocking room_member_handler=%r", room_member_handler)
|
||||
|
||||
@ -122,6 +119,11 @@ class PresenceStateTestCase(unittest.TestCase):
|
||||
return defer.succeed([])
|
||||
room_member_handler.get_room_members = get_room_members
|
||||
|
||||
def do_users_share_a_room(userlist):
|
||||
shared = all(map(lambda u: u in self.room_members, userlist))
|
||||
return defer.succeed(shared)
|
||||
self.datastore.do_users_share_a_room = do_users_share_a_room
|
||||
|
||||
self.mock_start = Mock()
|
||||
self.mock_stop = Mock()
|
||||
|
||||
|
@ -102,6 +102,10 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase):
|
||||
])
|
||||
self.datastore.get_presence_list = get_presence_list
|
||||
|
||||
def do_users_share_a_room(userlist):
|
||||
return defer.succeed(False)
|
||||
self.datastore.do_users_share_a_room = do_users_share_a_room
|
||||
|
||||
self.handlers = hs.get_handlers()
|
||||
|
||||
self.mock_update_client = Mock()
|
||||
|
@ -229,11 +229,19 @@ class PresenceEventStreamTestCase(unittest.TestCase):
|
||||
|
||||
# HIDEOUS HACKERY
|
||||
# TODO(paul): This should be injected in via the HomeServer DI system
|
||||
from synapse.handlers.events import EventStreamHandler
|
||||
from synapse.handlers.presence import PresenceStreamData
|
||||
EventStreamHandler.stream_data_classes = [
|
||||
PresenceStreamData
|
||||
]
|
||||
from synapse.streams.events import (
|
||||
PresenceSource, NullSource, EventSources
|
||||
)
|
||||
|
||||
old_SOURCE_TYPES = EventSources.SOURCE_TYPES
|
||||
def tearDown():
|
||||
EventSources.SOURCE_TYPES = old_SOURCE_TYPES
|
||||
self.tearDown = tearDown
|
||||
|
||||
EventSources.SOURCE_TYPES = {
|
||||
k: NullSource for k in old_SOURCE_TYPES.keys()
|
||||
}
|
||||
EventSources.SOURCE_TYPES["presence"] = PresenceSource
|
||||
|
||||
hs = HomeServer("test",
|
||||
db_pool=None,
|
||||
@ -288,7 +296,7 @@ class PresenceEventStreamTestCase(unittest.TestCase):
|
||||
# all be ours
|
||||
|
||||
# I'll already get my own presence state change
|
||||
self.assertEquals({"start": "1", "end": "1", "chunk": []}, response)
|
||||
self.assertEquals({"start": "0_1", "end": "0_1", "chunk": []}, response)
|
||||
|
||||
self.mock_datastore.set_presence_state.return_value = defer.succeed(
|
||||
{"state": ONLINE})
|
||||
@ -299,10 +307,10 @@ class PresenceEventStreamTestCase(unittest.TestCase):
|
||||
state={"state": ONLINE})
|
||||
|
||||
(code, response) = yield self.mock_resource.trigger("GET",
|
||||
"/events?from=1&timeout=0", None)
|
||||
"/events?from=0_1&timeout=0", None)
|
||||
|
||||
self.assertEquals(200, code)
|
||||
self.assertEquals({"start": "1", "end": "2", "chunk": [
|
||||
self.assertEquals({"start": "0_1", "end": "0_2", "chunk": [
|
||||
{"type": "m.presence",
|
||||
"content": {
|
||||
"user_id": "@banana:test",
|
||||
|
Loading…
Reference in New Issue
Block a user