Skip to content

Commit 67cf94b

Browse files
authored
UserLists version (#343)
* UserLists version * linter * adding to __init__ all resources * verification status inside resource * tested * v cv * version
1 parent 11e2608 commit 67cf94b

File tree

9 files changed

+184
-2
lines changed

9 files changed

+184
-2
lines changed

cuenca/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
'User',
3333
'UserCredential',
3434
'UserEvent',
35+
'UserListsValidation',
3536
'UserLogin',
3637
'Verification',
3738
'WalletTransaction',
@@ -77,6 +78,7 @@
7778
User,
7879
UserCredential,
7980
UserEvent,
81+
UserListsValidation,
8082
UserLogin,
8183
Verification,
8284
WalletTransaction,

cuenca/resources/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
'User',
3232
'UserEvent',
3333
'UserLogin',
34+
'UserListsValidation',
3435
'Verification',
3536
'WalletTransaction',
3637
'Webhook',
@@ -69,6 +70,7 @@
6970
from .transfers import Transfer
7071
from .user_credentials import UserCredential
7172
from .user_events import UserEvent
73+
from .user_lists_validation import UserListsValidation
7274
from .user_logins import UserLogin
7375
from .users import User
7476
from .verifications import Verification
@@ -109,6 +111,7 @@
109111
User,
110112
UserCredential,
111113
UserEvent,
114+
UserListsValidation,
112115
UserLogin,
113116
Verification,
114117
WalletTransaction,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import datetime as dt
2+
from typing import ClassVar, Optional, cast
3+
4+
from cuenca_validations.types import UserListsRequest, VerificationStatus
5+
from cuenca_validations.types.identities import CurpField
6+
7+
from ..http import Session, session as global_session
8+
from .base import Creatable, Retrievable
9+
10+
11+
class UserListsValidation(Creatable, Retrievable):
12+
_resource: ClassVar = 'user_lists_validations'
13+
created_at: dt.datetime
14+
names: Optional[str] = None
15+
first_surname: Optional[str] = None
16+
second_surname: Optional[str] = None
17+
curp: Optional[CurpField] = None
18+
account_number: Optional[str] = None
19+
status: Optional[VerificationStatus] = None
20+
21+
@classmethod
22+
def create(
23+
cls,
24+
names: Optional[str] = None,
25+
first_surname: Optional[str] = None,
26+
second_surname: Optional[str] = None,
27+
curp: Optional[CurpField] = None,
28+
account_number: Optional[str] = None,
29+
*,
30+
session: Session = global_session,
31+
) -> 'UserListsValidation':
32+
req = UserListsRequest(
33+
names=names,
34+
first_surname=first_surname,
35+
second_surname=second_surname,
36+
curp=curp,
37+
account_number=account_number,
38+
)
39+
return cast(
40+
'UserListsValidation',
41+
cls._create(session=session, **req.dict()),
42+
)

cuenca/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = '0.15.6'
1+
__version__ = '0.15.7'
22
CLIENT_VERSION = __version__
33
API_VERSION = '2020-03-19'

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
requests==2.27.1
2-
cuenca-validations==0.11.15
2+
cuenca-validations==0.11.17
33
dataclasses>=0.7;python_version<"3.7"

tests/conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ def user_request() -> Dict:
6363
return user_dict
6464

6565

66+
@pytest.fixture
67+
def user_lists_request() -> Dict:
68+
user_dict = dict(
69+
curp='LOHJ660606HDFPRS02',
70+
names='Alejandro',
71+
first_surname='Martinez',
72+
second_surname='Viquez',
73+
)
74+
return user_dict
75+
76+
6677
@pytest.fixture
6778
def file() -> BytesIO:
6879
with open('tests/data/test_file.jpeg', 'rb') as image_file:
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
interactions:
2+
- request:
3+
body: '{"curp": "LOHJ660606HDFPRS02", "account_number": null, "names": "Alejandro",
4+
"first_surname": "Martinez", "second_surname": "Viquez"}'
5+
headers:
6+
Accept:
7+
- '*/*'
8+
Accept-Encoding:
9+
- gzip, deflate
10+
Authorization:
11+
- DUMMY
12+
Connection:
13+
- keep-alive
14+
Content-Length:
15+
- '133'
16+
Content-Type:
17+
- application/json
18+
User-Agent:
19+
- cuenca-python/0.15.8.dev2
20+
X-Cuenca-Api-Version:
21+
- '2020-03-19'
22+
method: POST
23+
uri: https://sandbox.cuenca.com/user_lists_validations
24+
response:
25+
body:
26+
string: '{"id":"UVEb7dxQ9URaSPJ8T5AZx18w","created_at":"2023-01-26T22:31:43.776743","platform_id":"PTZbBlk__kQt-wfwzP5nwA9A","names":"Alejandro","first_surname":"Martinez","second_surname":"Viquez","curp":null,"status":"succeeded","error":null}'
27+
headers:
28+
Connection:
29+
- keep-alive
30+
Content-Length:
31+
- '235'
32+
Content-Type:
33+
- application/json
34+
Date:
35+
- Thu, 26 Jan 2023 22:31:49 GMT
36+
X-Request-Time:
37+
- 'value: 5.414'
38+
x-amz-apigw-id:
39+
- fXzUdE5-CYcFjcQ=
40+
x-amzn-Remapped-Connection:
41+
- keep-alive
42+
x-amzn-Remapped-Content-Length:
43+
- '235'
44+
x-amzn-Remapped-Date:
45+
- Thu, 26 Jan 2023 22:31:49 GMT
46+
x-amzn-Remapped-Server:
47+
- nginx/1.22.1
48+
x-amzn-RequestId:
49+
- d6df16fc-7de4-491c-8355-750fea51aa84
50+
status:
51+
code: 201
52+
message: Created
53+
version: 1
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
interactions:
2+
- request:
3+
body: '{"curp": null, "account_number": null, "names": null, "first_surname":
4+
null, "second_surname": null}'
5+
headers:
6+
Accept:
7+
- '*/*'
8+
Accept-Encoding:
9+
- gzip, deflate
10+
Authorization:
11+
- DUMMY
12+
Connection:
13+
- keep-alive
14+
Content-Length:
15+
- '100'
16+
Content-Type:
17+
- application/json
18+
User-Agent:
19+
- cuenca-python/0.15.8.dev2
20+
X-Cuenca-Api-Version:
21+
- '2020-03-19'
22+
method: POST
23+
uri: https://sandbox.cuenca.com/user_lists_validations
24+
response:
25+
body:
26+
string: '{"error":"There is an error with the inputs"}'
27+
headers:
28+
Connection:
29+
- keep-alive
30+
Content-Length:
31+
- '45'
32+
Content-Type:
33+
- application/json
34+
Date:
35+
- Thu, 26 Jan 2023 22:34:19 GMT
36+
x-amz-apigw-id:
37+
- fXzszEKAiYcFpjA=
38+
x-amzn-Remapped-Connection:
39+
- keep-alive
40+
x-amzn-Remapped-Content-Length:
41+
- '45'
42+
x-amzn-Remapped-Date:
43+
- Thu, 26 Jan 2023 22:34:19 GMT
44+
x-amzn-Remapped-Server:
45+
- nginx/1.22.1
46+
x-amzn-RequestId:
47+
- 7c91e271-c8ab-4fd7-a2c9-b7ab66f48daf
48+
status:
49+
code: 400
50+
message: Bad Request
51+
version: 1
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import pytest
2+
from cuenca_validations.types import VerificationStatus
3+
4+
from cuenca.exc import CuencaResponseException
5+
from cuenca.resources import UserListsValidation
6+
7+
8+
@pytest.mark.vcr
9+
def test_create_user_validation(user_lists_request):
10+
user_validation = UserListsValidation.create(**user_lists_request)
11+
assert user_validation.status == VerificationStatus.succeeded
12+
assert user_validation.id
13+
14+
15+
@pytest.mark.vcr
16+
def test_create_user_validation_invalid_inputs():
17+
with pytest.raises(CuencaResponseException) as exc:
18+
UserListsValidation.create(**dict())
19+
assert exc.status_code == 403
20+
assert exc.json['error'] == 'There is an error with the inputs'

0 commit comments

Comments
 (0)