Some checks failed
CI/CD Pipeline / Telegram Notify Success (push) Has been cancelled
CI/CD Pipeline / Run Tests (push) Has been cancelled
CI/CD Pipeline / Code Quality Checks (push) Has been cancelled
CI/CD Pipeline / Code Quality Checks (pull_request) Successful in 1m42s
CI/CD Pipeline / Run Tests (pull_request) Successful in 2m25s
CI/CD Pipeline / Telegram Notify Success (pull_request) Successful in 1m34s
25 lines
892 B
Python
25 lines
892 B
Python
"""Tests for core pagination classes."""
|
|
|
|
from apps.core.pagination import StandardCursorPagination, StandardPagination
|
|
from django.test import SimpleTestCase
|
|
|
|
|
|
class PaginationSchemaTest(SimpleTestCase):
|
|
def test_standard_pagination_schema(self):
|
|
schema = StandardPagination().get_paginated_response_schema({"type": "array"})
|
|
|
|
self.assertEqual(schema["type"], "object")
|
|
self.assertEqual(schema["properties"]["data"]["type"], "array")
|
|
|
|
def test_cursor_pagination_schema(self):
|
|
schema = StandardCursorPagination().get_paginated_response_schema(
|
|
{"type": "array"}
|
|
)
|
|
|
|
self.assertEqual(schema["type"], "object")
|
|
pagination = schema["properties"]["meta"]["properties"]["pagination"][
|
|
"properties"
|
|
]
|
|
self.assertIn("next_cursor", pagination)
|
|
self.assertIn("previous_cursor", pagination)
|