-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add paginator test cases and support for json next link paginator
- Loading branch information
Showing
5 changed files
with
170 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: 'pagination' | ||
version: 1.0.0 | ||
description: 'different pagination examples' | ||
servers: | ||
- url: 'https://pokeapi.co/' | ||
|
||
paths: | ||
/offset_limit_pagination_1/: | ||
get: | ||
operationId: offset_limit_pagination_1 | ||
parameters: | ||
- in: query | ||
name: limit | ||
schema: | ||
description: Number of results to return per page. | ||
title: Limit | ||
type: integer | ||
- in: query | ||
name: offset | ||
schema: | ||
description: The initial index from which to return the results. | ||
title: Offset | ||
type: integer | ||
responses: | ||
'200': | ||
description: "OK" | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
count: | ||
type: integer | ||
example: 3 | ||
next: | ||
type: string | ||
nullable: true | ||
example: https://pokeapi.co/api/v2/pokemon/?offset=20&limit=20 | ||
previous: | ||
type: string | ||
nullable: true | ||
results: | ||
type: array | ||
|
||
/cursor_pagination_1/: | ||
get: | ||
operationId: cursor_pagination_1 | ||
parameters: | ||
- in: query | ||
name: cursor | ||
schema: | ||
description: Put cursor here | ||
title: Cursor | ||
type: string | ||
responses: | ||
'200': | ||
description: "OK" | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
cursor: | ||
type: string | ||
results: | ||
type: array | ||
|
||
|
||
/json_links_pagination_1/: | ||
get: | ||
operationId: json_links_pagination_1 | ||
responses: | ||
'200': | ||
description: "OK" | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
count: | ||
type: integer | ||
example: 3 | ||
next: | ||
type: string | ||
nullable: true | ||
example: https://pokeapi.co/api/v2/pokemon/?offset=20&limit=20 | ||
previous: | ||
type: string | ||
nullable: true | ||
results: | ||
type: array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from typing import Dict, Any | ||
|
||
import pytest | ||
|
||
from tests.e2e.utils import get_source_from_open_api, get_dict_from_open_api | ||
from tests.cases import get_test_case_path | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def paginators() -> Dict[str, Any]: | ||
case_path = get_test_case_path("pagination_specs.yml") | ||
# validate that source will work | ||
get_source_from_open_api(case_path) | ||
|
||
# get dict and save paginator info into dict | ||
rendered_dict = get_dict_from_open_api(case_path) | ||
return { | ||
entry["name"]: entry.get("endpoint").get("paginator") for entry in rendered_dict["resources"] # type: ignore | ||
} | ||
|
||
|
||
def test_offset_limit_pagination_1(paginators: Dict[str, Any]) -> None: | ||
assert paginators["offset_limit_pagination_1"] == { | ||
"initial_limit": 20, | ||
"limit_param": "limit", | ||
"offset_param": "offset", | ||
"type": "offset", | ||
"total_path": "count", | ||
} | ||
|
||
|
||
def test_json_links_pagination_1(paginators: Dict[str, Any]) -> None: | ||
assert paginators["json_links_pagination_1"] == { | ||
"next_url_path": "next", | ||
"type": "json_links", | ||
} | ||
|
||
|
||
def test_json_cursor_1(paginators: Dict[str, Any]) -> None: | ||
assert paginators["cursor_pagination_1"] == {"cursor_param": "cursor", "cursor_path": "cursor", "type": "cursor"} |