Skip to content

Commit dd58df4

Browse files
committed
Add tests
1 parent 7a717d0 commit dd58df4

File tree

5 files changed

+145
-0
lines changed

5 files changed

+145
-0
lines changed

cuenca/resources/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
WhatsappTransfer,
129129
Webhook,
130130
Platform,
131+
PostalCodes,
131132
JwtToken,
132133
TermsOfService,
133134
UserTOSAgreement,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
User-Agent:
6+
- cuenca-python/2.1.5
7+
X-Cuenca-Api-Version:
8+
- '2020-03-19'
9+
method: GET
10+
uri: https://sandbox.cuenca.com/postal_codes?postal_code=40106
11+
response:
12+
body:
13+
string: "{\"items\":[{\"id\":\"PCqpCtquNnTTWj4afusCWbXQ\",\"created_at\":\"2025-06-25T18:44:14.409000\",\"postal_code\":\"40106\",\"colonia\":\"El
14+
Naranjo\",\"city\":\"Iguala de la Independencia\",\"state\":\"GR\",\"state_name\":\"Guerrero\",\"country\":\"MX\",\"country_name\":\"M\xE9xico\"},{\"id\":\"PCN2-h_t4ASn-yr46-5C352g\",\"created_at\":\"2025-06-25T18:44:14.409000\",\"postal_code\":\"40106\",\"colonia\":\"Ficus\",\"city\":\"Iguala
15+
de la Independencia\",\"state\":\"GR\",\"state_name\":\"Guerrero\",\"country\":\"MX\",\"country_name\":\"M\xE9xico\"}],\"next_page_uri\":null}"
16+
headers:
17+
Connection:
18+
- keep-alive
19+
Content-Length:
20+
- '495'
21+
Content-Type:
22+
- application/json
23+
Date:
24+
- Thu, 03 Jul 2025 18:44:22 GMT
25+
X-Request-Time:
26+
- 'value: 0.045'
27+
x-amz-apigw-id:
28+
- NJVdFHJXCYcEPzw=
29+
x-amzn-Remapped-Connection:
30+
- keep-alive
31+
x-amzn-Remapped-Content-Length:
32+
- '495'
33+
x-amzn-Remapped-Date:
34+
- Thu, 03 Jul 2025 18:44:22 GMT
35+
x-amzn-Remapped-Server:
36+
- nginx/1.28.0
37+
x-amzn-RequestId:
38+
- 3ff50d45-d63b-4244-9bba-9f7dc776d4bb
39+
status:
40+
code: 200
41+
message: OK
42+
version: 1
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
User-Agent:
6+
- cuenca-python/2.1.5
7+
X-Cuenca-Api-Version:
8+
- '2020-03-19'
9+
method: GET
10+
uri: https://sandbox.cuenca.com/postal_codes?postal_code=401000
11+
response:
12+
body:
13+
string: '{"items":[],"next_page_uri":null}'
14+
headers:
15+
Connection:
16+
- keep-alive
17+
Content-Length:
18+
- '33'
19+
Content-Type:
20+
- application/json
21+
Date:
22+
- Thu, 03 Jul 2025 18:44:22 GMT
23+
X-Request-Time:
24+
- 'value: 0.044'
25+
x-amz-apigw-id:
26+
- NJVdIFzWCYcEQnA=
27+
x-amzn-Remapped-Connection:
28+
- keep-alive
29+
x-amzn-Remapped-Content-Length:
30+
- '33'
31+
x-amzn-Remapped-Date:
32+
- Thu, 03 Jul 2025 18:44:22 GMT
33+
x-amzn-Remapped-Server:
34+
- nginx/1.28.0
35+
x-amzn-RequestId:
36+
- 00d3f3a3-2fb5-4b74-8fbf-8ac6dc615ae7
37+
status:
38+
code: 200
39+
message: OK
40+
version: 1
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
User-Agent:
6+
- cuenca-python/2.1.5
7+
X-Cuenca-Api-Version:
8+
- '2020-03-19'
9+
method: GET
10+
uri: https://sandbox.cuenca.com/postal_codes?postal_code=40100
11+
response:
12+
body:
13+
string: "{\"items\":[{\"id\":\"PCHOECy9u6QQeXPR6HdR5Bgw\",\"created_at\":\"2025-06-25T18:44:14.409000\",\"postal_code\":\"40100\",\"colonia\":\"Metlapa\",\"city\":\"Iguala
14+
de la Independencia\",\"state\":\"GR\",\"state_name\":\"Guerrero\",\"country\":\"MX\",\"country_name\":\"M\xE9xico\"}],\"next_page_uri\":null}"
15+
headers:
16+
Connection:
17+
- keep-alive
18+
Content-Length:
19+
- '263'
20+
Content-Type:
21+
- application/json
22+
Date:
23+
- Thu, 03 Jul 2025 18:42:12 GMT
24+
X-Request-Time:
25+
- 'value: 0.046'
26+
x-amz-apigw-id:
27+
- NJVIwHRyCYcEeIw=
28+
x-amzn-Remapped-Connection:
29+
- keep-alive
30+
x-amzn-Remapped-Content-Length:
31+
- '263'
32+
x-amzn-Remapped-Date:
33+
- Thu, 03 Jul 2025 18:42:12 GMT
34+
x-amzn-Remapped-Server:
35+
- nginx/1.28.0
36+
x-amzn-RequestId:
37+
- 75a527b3-8a33-42ed-8633-23dd2b1ddeff
38+
status:
39+
code: 200
40+
message: OK
41+
version: 1
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import pytest
2+
3+
from cuenca.resources import PostalCodes
4+
5+
6+
@pytest.mark.vcr
7+
def test_postal_codes_retrieve_one_colony() -> None:
8+
postal_codes = list(PostalCodes.all(postal_code='40100'))
9+
assert len(postal_codes) == 1
10+
11+
12+
@pytest.mark.vcr
13+
def test_postal_codes_retrieve_multiple_colony() -> None:
14+
postal_codes = list(PostalCodes.all(postal_code='40106'))
15+
assert len(postal_codes) > 1
16+
17+
18+
@pytest.mark.vcr
19+
def test_postal_codes_retrieve_not_found() -> None:
20+
postal_codes = list(PostalCodes.all(postal_code='401000'))
21+
assert len(postal_codes) == 0

0 commit comments

Comments
 (0)