Skip to content

Commit 3915a41

Browse files
fix: verify url to garantee that in multiples calls, the base_url will be called just once
1 parent 0289d1c commit 3915a41

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

api-batch-test/src/api_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ def _build_url(self, endpoint: str, **path_params) -> str:
4141
"""Constrói a URL completa formatando parametros de caminho."""
4242
if path_params:
4343
endpoint = endpoint.format(**path_params)
44+
# Se já é uma URL completa, retorna como está
45+
if endpoint.startswith("http://") or endpoint.startswith("https://"):
46+
return endpoint
4447
return f"{self.base_url}/{endpoint.lstrip('/')}"
4548

4649
def get(self, endpoint: str, params=None, **kwargs) -> requests.Response:

api-batch-test/tests/test_people_pagination.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from tests.helpers.pagination import iter_pages
2+
from src.api_endpoints import Endpoints
3+
24
import pytest
35

46
@pytest.mark.pagination
@@ -8,7 +10,7 @@ def test_people_pagination_integrity(http):
810
total_items = 0
911
page_index = 0
1012

11-
for page in iter_pages(http, "/people/"):
13+
for page in iter_pages(http, Endpoints.PEOPLE):
1214
if total_count is None:
1315
total_count = page["count"]
1416
assert page["previous"] is None

0 commit comments

Comments
 (0)