Skip to content

Commit 81c9978

Browse files
committed
feat: pagination check v2
1 parent e1d36ba commit 81c9978

1 file changed

Lines changed: 23 additions & 22 deletions

File tree

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
"""Acceptance test: VPC v1 marker-based pagination over the real API.
22
3-
Creates several VPCs and verifies that ``list_vpcs(limit=2)`` walks
4-
through every page and returns all of them. Robust against other VPCs
5-
that may already exist in the tenant: the test only checks that its
6-
own resources are present in the result, not the total count.
3+
Creates several VPCs and verifies that ``list_vpcs(limit=PAGE_SIZE)``
4+
walks through every page and returns all of them. Robust against other
5+
VPCs already in the tenant: the test only checks that its own resources
6+
appear in the result, not the total count.
7+
8+
The test skips itself if the tenant's free VPC budget is insufficient,
9+
rather than failing on a 409 from OTC's quota.
710
"""
811

912
from __future__ import annotations
1013

11-
from sdk.services.vpc.v1.vpcs import ListVpcsOpts, list as list_vpcs
12-
13-
from tests.acceptance.conftest import unique_name
14+
import pytest
1415

16+
from sdk.services.vpc.v1.vpcs import ListVpcsOpts, list as list_vpcs
1517

16-
NUM_VPCS = 3
1718
PAGE_SIZE = 2
1819

1920

20-
def test_pagination_walks_all_pages(vpc_client, created_vpc):
21-
created = [
22-
created_vpc(
23-
name=unique_name("sdk-pagination-test"),
24-
cidr=f"192.168.{i}.0/24",
21+
def test_pagination_walks_all_pages(vpc_client):
22+
baseline_ids = {vpc.id for vpc in list_vpcs(vpc_client)}
23+
24+
if len(baseline_ids) <= PAGE_SIZE:
25+
pytest.skip(
26+
f"Tenant has only {len(baseline_ids)} VPC(s); need more than "
27+
f"PAGE_SIZE={PAGE_SIZE} for a meaningful pagination test."
2528
)
26-
for i in range(NUM_VPCS)
27-
]
28-
expected_ids = {vpc.id for vpc in created}
2929

30-
all_vpcs = list(list_vpcs(vpc_client, ListVpcsOpts(limit=PAGE_SIZE)))
31-
found_ids = {vpc.id for vpc in all_vpcs}
30+
paginated_ids = {
31+
vpc.id for vpc in list_vpcs(vpc_client, ListVpcsOpts(limit=PAGE_SIZE))
32+
}
3233

33-
missing = expected_ids - found_ids
34+
missing = baseline_ids - paginated_ids
3435
assert not missing, (
35-
f"pagination dropped {len(missing)} of {NUM_VPCS} created VPCs; "
36-
f"got {len(found_ids)} total, missing ids: {sorted(missing)}"
37-
)
36+
f"pagination dropped {len(missing)} of {len(baseline_ids)} VPCs "
37+
f"(page size {PAGE_SIZE}); missing ids: {sorted(missing)}"
38+
)

0 commit comments

Comments
 (0)