mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Fix the presence tests
This commit is contained in:
parent
1a9a9abcc7
commit
17167898c8
@ -233,7 +233,7 @@ class MockedDatastorePresenceTestCase(PresenceTestCase):
|
|||||||
if not user_localpart in self.PRESENCE_LIST:
|
if not user_localpart in self.PRESENCE_LIST:
|
||||||
return defer.succeed([])
|
return defer.succeed([])
|
||||||
return defer.succeed([
|
return defer.succeed([
|
||||||
{"observed_user_id": u} for u in
|
{"observed_user_id": u, "accepted": accepted} for u in
|
||||||
self.PRESENCE_LIST[user_localpart]])
|
self.PRESENCE_LIST[user_localpart]])
|
||||||
datastore.get_presence_list = get_presence_list
|
datastore.get_presence_list = get_presence_list
|
||||||
|
|
||||||
@ -734,10 +734,12 @@ class PresencePushTestCase(MockedDatastorePresenceTestCase):
|
|||||||
|
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
[
|
[
|
||||||
{"observed_user": self.u_banana,
|
{"observed_user": self.u_banana,
|
||||||
"presence": OFFLINE},
|
"presence": OFFLINE,
|
||||||
|
"accepted": True},
|
||||||
{"observed_user": self.u_clementine,
|
{"observed_user": self.u_clementine,
|
||||||
"presence": OFFLINE},
|
"presence": OFFLINE,
|
||||||
|
"accepted": True},
|
||||||
],
|
],
|
||||||
presence
|
presence
|
||||||
)
|
)
|
||||||
@ -758,9 +760,11 @@ class PresencePushTestCase(MockedDatastorePresenceTestCase):
|
|||||||
self.assertEquals([
|
self.assertEquals([
|
||||||
{"observed_user": self.u_banana,
|
{"observed_user": self.u_banana,
|
||||||
"presence": ONLINE,
|
"presence": ONLINE,
|
||||||
"last_active_ago": 2000},
|
"last_active_ago": 2000,
|
||||||
|
"accepted": True},
|
||||||
{"observed_user": self.u_clementine,
|
{"observed_user": self.u_clementine,
|
||||||
"presence": OFFLINE},
|
"presence": OFFLINE,
|
||||||
|
"accepted": True},
|
||||||
], presence)
|
], presence)
|
||||||
|
|
||||||
(events, _) = yield self.event_source.get_new_events_for_user(
|
(events, _) = yield self.event_source.get_new_events_for_user(
|
||||||
|
@ -101,8 +101,8 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase):
|
|||||||
self.datastore.get_profile_avatar_url = get_profile_avatar_url
|
self.datastore.get_profile_avatar_url = get_profile_avatar_url
|
||||||
|
|
||||||
self.presence_list = [
|
self.presence_list = [
|
||||||
{"observed_user_id": "@banana:test"},
|
{"observed_user_id": "@banana:test", "accepted": True},
|
||||||
{"observed_user_id": "@clementine:test"},
|
{"observed_user_id": "@clementine:test", "accepted": True},
|
||||||
]
|
]
|
||||||
def get_presence_list(user_localpart, accepted=None):
|
def get_presence_list(user_localpart, accepted=None):
|
||||||
return defer.succeed(self.presence_list)
|
return defer.succeed(self.presence_list)
|
||||||
@ -144,8 +144,8 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_set_my_state(self):
|
def test_set_my_state(self):
|
||||||
self.presence_list = [
|
self.presence_list = [
|
||||||
{"observed_user_id": "@banana:test"},
|
{"observed_user_id": "@banana:test", "accepted": True},
|
||||||
{"observed_user_id": "@clementine:test"},
|
{"observed_user_id": "@clementine:test", "accepted": True},
|
||||||
]
|
]
|
||||||
|
|
||||||
mocked_set = self.datastore.set_presence_state
|
mocked_set = self.datastore.set_presence_state
|
||||||
@ -167,8 +167,8 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase):
|
|||||||
self.mock_get_joined.side_effect = get_joined
|
self.mock_get_joined.side_effect = get_joined
|
||||||
|
|
||||||
self.presence_list = [
|
self.presence_list = [
|
||||||
{"observed_user_id": "@banana:test"},
|
{"observed_user_id": "@banana:test", "accepted": True},
|
||||||
{"observed_user_id": "@clementine:test"},
|
{"observed_user_id": "@clementine:test", "accepted": True},
|
||||||
]
|
]
|
||||||
|
|
||||||
self.datastore.set_presence_state.return_value = defer.succeed(
|
self.datastore.set_presence_state.return_value = defer.succeed(
|
||||||
@ -203,9 +203,11 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase):
|
|||||||
"presence": ONLINE,
|
"presence": ONLINE,
|
||||||
"last_active_ago": 0,
|
"last_active_ago": 0,
|
||||||
"displayname": "Frank",
|
"displayname": "Frank",
|
||||||
"avatar_url": "http://foo"},
|
"avatar_url": "http://foo",
|
||||||
|
"accepted": True},
|
||||||
{"observed_user": self.u_clementine,
|
{"observed_user": self.u_clementine,
|
||||||
"presence": OFFLINE}
|
"presence": OFFLINE,
|
||||||
|
"accepted": True}
|
||||||
], presence)
|
], presence)
|
||||||
|
|
||||||
self.mock_update_client.assert_has_calls([
|
self.mock_update_client.assert_has_calls([
|
||||||
@ -233,7 +235,7 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_push_remote(self):
|
def test_push_remote(self):
|
||||||
self.presence_list = [
|
self.presence_list = [
|
||||||
{"observed_user_id": "@potato:remote"},
|
{"observed_user_id": "@potato:remote", "accepted": True},
|
||||||
]
|
]
|
||||||
|
|
||||||
self.datastore.set_presence_state.return_value = defer.succeed(
|
self.datastore.set_presence_state.return_value = defer.succeed(
|
||||||
|
@ -183,7 +183,7 @@ class PresenceListTestCase(unittest.TestCase):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_get_my_list(self):
|
def test_get_my_list(self):
|
||||||
self.datastore.get_presence_list.return_value = defer.succeed(
|
self.datastore.get_presence_list.return_value = defer.succeed(
|
||||||
[{"observed_user_id": "@banana:test"}],
|
[{"observed_user_id": "@banana:test", "accepted": True}],
|
||||||
)
|
)
|
||||||
|
|
||||||
(code, response) = yield self.mock_resource.trigger("GET",
|
(code, response) = yield self.mock_resource.trigger("GET",
|
||||||
@ -191,7 +191,7 @@ class PresenceListTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEquals(200, code)
|
self.assertEquals(200, code)
|
||||||
self.assertEquals([
|
self.assertEquals([
|
||||||
{"user_id": "@banana:test", "presence": OFFLINE},
|
{"user_id": "@banana:test", "presence": OFFLINE, "accepted": True},
|
||||||
], response)
|
], response)
|
||||||
|
|
||||||
self.datastore.get_presence_list.assert_called_with(
|
self.datastore.get_presence_list.assert_called_with(
|
||||||
|
Loading…
Reference in New Issue
Block a user