|
24 | 24 | from synapse.rest import admin
|
25 | 25 | from synapse.rest.client import login, register, relations, room, sync
|
26 | 26 | from synapse.server import HomeServer
|
27 |
| -from synapse.storage.relations import RelationPaginationToken |
28 |
| -from synapse.types import JsonDict, StreamToken |
| 27 | +from synapse.types import JsonDict |
29 | 28 | from synapse.util import Clock
|
30 | 29 |
|
31 | 30 | from tests import unittest
|
@@ -281,15 +280,6 @@ def test_basic_paginate_relations(self) -> None:
|
281 | 280 | channel.json_body["chunk"][0],
|
282 | 281 | )
|
283 | 282 |
|
284 |
| - def _stream_token_to_relation_token(self, token: str) -> str: |
285 |
| - """Convert a StreamToken into a legacy token (RelationPaginationToken).""" |
286 |
| - room_key = self.get_success(StreamToken.from_string(self.store, token)).room_key |
287 |
| - return self.get_success( |
288 |
| - RelationPaginationToken( |
289 |
| - topological=room_key.topological, stream=room_key.stream |
290 |
| - ).to_string(self.store) |
291 |
| - ) |
292 |
| - |
293 | 283 | def test_repeated_paginate_relations(self) -> None:
|
294 | 284 | """Test that if we paginate using a limit and tokens then we get the
|
295 | 285 | expected events.
|
@@ -330,34 +320,6 @@ def test_repeated_paginate_relations(self) -> None:
|
330 | 320 | found_event_ids.reverse()
|
331 | 321 | self.assertEqual(found_event_ids, expected_event_ids)
|
332 | 322 |
|
333 |
| - # Reset and try again, but convert the tokens to the legacy format. |
334 |
| - prev_token = "" |
335 |
| - found_event_ids = [] |
336 |
| - for _ in range(20): |
337 |
| - from_token = "" |
338 |
| - if prev_token: |
339 |
| - from_token = "&from=" + self._stream_token_to_relation_token(prev_token) |
340 |
| - |
341 |
| - channel = self.make_request( |
342 |
| - "GET", |
343 |
| - f"/_matrix/client/unstable/rooms/{self.room}/relations/{self.parent_id}?limit=1{from_token}", |
344 |
| - access_token=self.user_token, |
345 |
| - ) |
346 |
| - self.assertEqual(200, channel.code, channel.json_body) |
347 |
| - |
348 |
| - found_event_ids.extend(e["event_id"] for e in channel.json_body["chunk"]) |
349 |
| - next_batch = channel.json_body.get("next_batch") |
350 |
| - |
351 |
| - self.assertNotEqual(prev_token, next_batch) |
352 |
| - prev_token = next_batch |
353 |
| - |
354 |
| - if not prev_token: |
355 |
| - break |
356 |
| - |
357 |
| - # We paginated backwards, so reverse |
358 |
| - found_event_ids.reverse() |
359 |
| - self.assertEqual(found_event_ids, expected_event_ids) |
360 |
| - |
361 | 323 | def test_pagination_from_sync_and_messages(self) -> None:
|
362 | 324 | """Pagination tokens from /sync and /messages can be used to paginate /relations."""
|
363 | 325 | channel = self._send_relation(RelationTypes.ANNOTATION, "m.reaction", "A")
|
@@ -543,39 +505,6 @@ def test_aggregation_pagination_within_group(self) -> None:
|
543 | 505 | found_event_ids.reverse()
|
544 | 506 | self.assertEqual(found_event_ids, expected_event_ids)
|
545 | 507 |
|
546 |
| - # Reset and try again, but convert the tokens to the legacy format. |
547 |
| - prev_token = "" |
548 |
| - found_event_ids = [] |
549 |
| - for _ in range(20): |
550 |
| - from_token = "" |
551 |
| - if prev_token: |
552 |
| - from_token = "&from=" + self._stream_token_to_relation_token(prev_token) |
553 |
| - |
554 |
| - channel = self.make_request( |
555 |
| - "GET", |
556 |
| - f"/_matrix/client/unstable/rooms/{self.room}" |
557 |
| - f"/aggregations/{self.parent_id}/{RelationTypes.ANNOTATION}" |
558 |
| - f"/m.reaction/{encoded_key}?limit=1{from_token}", |
559 |
| - access_token=self.user_token, |
560 |
| - ) |
561 |
| - self.assertEqual(200, channel.code, channel.json_body) |
562 |
| - |
563 |
| - self.assertEqual(len(channel.json_body["chunk"]), 1, channel.json_body) |
564 |
| - |
565 |
| - found_event_ids.extend(e["event_id"] for e in channel.json_body["chunk"]) |
566 |
| - |
567 |
| - next_batch = channel.json_body.get("next_batch") |
568 |
| - |
569 |
| - self.assertNotEqual(prev_token, next_batch) |
570 |
| - prev_token = next_batch |
571 |
| - |
572 |
| - if not prev_token: |
573 |
| - break |
574 |
| - |
575 |
| - # We paginated backwards, so reverse |
576 |
| - found_event_ids.reverse() |
577 |
| - self.assertEqual(found_event_ids, expected_event_ids) |
578 |
| - |
579 | 508 | def test_aggregation(self) -> None:
|
580 | 509 | """Test that annotations get correctly aggregated."""
|
581 | 510 |
|
|
0 commit comments