mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-06 04:54:15 -04:00
Add simple pagination API
This commit is contained in:
parent
efe3c7977a
commit
b50641e357
3 changed files with 160 additions and 0 deletions
|
@ -72,6 +72,36 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
channel = self._send_relation(RelationTypes.ANNOTATION, EventTypes.Member)
|
||||
self.assertEquals(400, channel.code, channel.json_body)
|
||||
|
||||
def test_paginate(self):
|
||||
"""Tests that calling pagination API corectly the latest relations.
|
||||
"""
|
||||
channel = self._send_relation(RelationTypes.ANNOTATION, "m.reaction")
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
channel = self._send_relation(RelationTypes.ANNOTATION, "m.reaction")
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
annotation_id = channel.json_body["event_id"]
|
||||
|
||||
request, channel = self.make_request(
|
||||
"GET",
|
||||
"/_matrix/client/unstable/rooms/%s/relations/%s?limit=1"
|
||||
% (self.room, self.parent_id),
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
# We expect to get back a single pagination result, which is the full
|
||||
# relation event we sent above.
|
||||
self.assertEquals(len(channel.json_body["chunk"]), 1, channel.json_body)
|
||||
self.assert_dict(
|
||||
{
|
||||
"event_id": annotation_id,
|
||||
"sender": self.user_id,
|
||||
"type": "m.reaction",
|
||||
},
|
||||
channel.json_body["chunk"][0],
|
||||
)
|
||||
|
||||
def _send_relation(self, relation_type, event_type, key=None):
|
||||
"""Helper function to send a relation pointing at `self.parent_id`
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue