Skip to content

Commit 26383e1

Browse files
authored
add test case (#3208)
1 parent 423bd8e commit 26383e1

2 files changed

Lines changed: 129 additions & 0 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# -------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for
4+
# license information.
5+
# --------------------------------------------------------------------------
6+
import pytest
7+
from payload.pageable.aio import PageableClient
8+
9+
10+
@pytest.fixture
11+
async def client():
12+
async with PageableClient(endpoint="http://localhost:3000") as client:
13+
yield client
14+
15+
16+
def assert_result(result):
17+
assert len(result) == 4
18+
assert result[0].id == "1"
19+
assert result[1].id == "2"
20+
assert result[2].id == "3"
21+
assert result[3].id == "4"
22+
assert result[0].name == "dog"
23+
assert result[1].name == "cat"
24+
assert result[2].name == "bird"
25+
assert result[3].name == "fish"
26+
27+
28+
@pytest.mark.asyncio
29+
async def test_link(client: PageableClient):
30+
result = [p async for p in client.server_driven_pagination.link()]
31+
assert_result(result)
32+
33+
34+
@pytest.mark.asyncio
35+
async def test_request_query_response_body(client: PageableClient):
36+
result = [
37+
p
38+
async for p in client.server_driven_pagination.continuation_token.request_query_response_body(
39+
foo="foo", bar="bar"
40+
)
41+
]
42+
assert_result(result)
43+
44+
45+
@pytest.mark.asyncio
46+
async def test_request_header_response_body(client: PageableClient):
47+
result = [
48+
p
49+
async for p in client.server_driven_pagination.continuation_token.request_header_response_body(
50+
foo="foo", bar="bar"
51+
)
52+
]
53+
assert_result(result)
54+
55+
56+
@pytest.mark.asyncio
57+
async def test_request_query_response_header(client: PageableClient):
58+
result = [
59+
p
60+
async for p in client.server_driven_pagination.continuation_token.request_query_response_header(
61+
foo="foo", bar="bar"
62+
)
63+
]
64+
assert_result(result)
65+
66+
67+
@pytest.mark.asyncio
68+
async def test_request_header_response_header(client: PageableClient):
69+
result = [
70+
p
71+
async for p in client.server_driven_pagination.continuation_token.request_query_response_header(
72+
foo="foo", bar="bar"
73+
)
74+
]
75+
assert_result(result)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# -------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for
4+
# license information.
5+
# --------------------------------------------------------------------------
6+
import pytest
7+
from payload.pageable import PageableClient
8+
9+
10+
@pytest.fixture
11+
def client():
12+
with PageableClient(endpoint="http://localhost:3000") as client:
13+
yield client
14+
15+
16+
def assert_result(result):
17+
assert len(result) == 4
18+
assert result[0].id == "1"
19+
assert result[1].id == "2"
20+
assert result[2].id == "3"
21+
assert result[3].id == "4"
22+
assert result[0].name == "dog"
23+
assert result[1].name == "cat"
24+
assert result[2].name == "bird"
25+
assert result[3].name == "fish"
26+
27+
28+
def test_link(client: PageableClient):
29+
result = list(client.server_driven_pagination.link())
30+
assert_result(result)
31+
32+
33+
def test_request_query_response_body(client: PageableClient):
34+
result = list(client.server_driven_pagination.continuation_token.request_query_response_body(foo="foo", bar="bar"))
35+
assert_result(result)
36+
37+
38+
def test_request_header_response_body(client: PageableClient):
39+
result = list(client.server_driven_pagination.continuation_token.request_header_response_body(foo="foo", bar="bar"))
40+
assert_result(result)
41+
42+
43+
def test_request_query_response_header(client: PageableClient):
44+
result = list(
45+
client.server_driven_pagination.continuation_token.request_query_response_header(foo="foo", bar="bar")
46+
)
47+
assert_result(result)
48+
49+
50+
def test_request_header_response_header(client: PageableClient):
51+
result = list(
52+
client.server_driven_pagination.continuation_token.request_header_response_header(foo="foo", bar="bar")
53+
)
54+
assert_result(result)

0 commit comments

Comments
 (0)