Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cuenca/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
'User',
'UserCredential',
'UserEvent',
'UserListsValidation',
'UserLogin',
'Verification',
'WalletTransaction',
Expand Down Expand Up @@ -77,6 +78,7 @@
User,
UserCredential,
UserEvent,
UserListsValidation,
UserLogin,
Verification,
WalletTransaction,
Expand Down
3 changes: 3 additions & 0 deletions cuenca/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'User',
'UserEvent',
'UserLogin',
'UserListsValidation',
'Verification',
'WalletTransaction',
'Webhook',
Expand Down Expand Up @@ -69,6 +70,7 @@
from .transfers import Transfer
from .user_credentials import UserCredential
from .user_events import UserEvent
from .user_lists_validation import UserListsValidation
from .user_logins import UserLogin
from .users import User
from .verifications import Verification
Expand Down Expand Up @@ -109,6 +111,7 @@
User,
UserCredential,
UserEvent,
UserListsValidation,
UserLogin,
Verification,
WalletTransaction,
Expand Down
42 changes: 42 additions & 0 deletions cuenca/resources/user_lists_validation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import datetime as dt
from typing import ClassVar, Optional, cast

from cuenca_validations.types import UserListsRequest, VerificationStatus
from cuenca_validations.types.identities import CurpField

from ..http import Session, session as global_session
from .base import Creatable, Retrievable


class UserListsValidation(Creatable, Retrievable):
_resource: ClassVar = 'user_lists_validations'
created_at: dt.datetime
names: Optional[str] = None
first_surname: Optional[str] = None
second_surname: Optional[str] = None
curp: Optional[CurpField] = None
account_number: Optional[str] = None
status: Optional[VerificationStatus] = None

@classmethod
def create(
cls,
names: Optional[str] = None,
first_surname: Optional[str] = None,
second_surname: Optional[str] = None,
curp: Optional[CurpField] = None,
account_number: Optional[str] = None,
*,
session: Session = global_session,
) -> 'UserListsValidation':
req = UserListsRequest(
names=names,
first_surname=first_surname,
second_surname=second_surname,
curp=curp,
account_number=account_number,
)
return cast(
'UserListsValidation',
cls._create(session=session, **req.dict()),
)
2 changes: 1 addition & 1 deletion cuenca/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = '0.15.6'
__version__ = '0.15.7'
CLIENT_VERSION = __version__
API_VERSION = '2020-03-19'
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
requests==2.27.1
cuenca-validations==0.11.15
cuenca-validations==0.11.17
dataclasses>=0.7;python_version<"3.7"
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ def user_request() -> Dict:
return user_dict


@pytest.fixture
def user_lists_request() -> Dict:
user_dict = dict(
curp='LOHJ660606HDFPRS02',
names='Alejandro',
first_surname='Martinez',
second_surname='Viquez',
Comment on lines +69 to +72
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esta prueba está hecha con un curp que no existe, esto no afecta en nada?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No afecta, si no existe validamos con nombres

)
return user_dict


@pytest.fixture
def file() -> BytesIO:
with open('tests/data/test_file.jpeg', 'rb') as image_file:
Expand Down
53 changes: 53 additions & 0 deletions tests/resources/cassettes/test_create_user_validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
interactions:
- request:
body: '{"curp": "LOHJ660606HDFPRS02", "account_number": null, "names": "Alejandro",
"first_surname": "Martinez", "second_surname": "Viquez"}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- DUMMY
Connection:
- keep-alive
Content-Length:
- '133'
Content-Type:
- application/json
User-Agent:
- cuenca-python/0.15.8.dev2
X-Cuenca-Api-Version:
- '2020-03-19'
method: POST
uri: https://sandbox.cuenca.com/user_lists_validations
response:
body:
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}'
headers:
Connection:
- keep-alive
Content-Length:
- '235'
Content-Type:
- application/json
Date:
- Thu, 26 Jan 2023 22:31:49 GMT
X-Request-Time:
- 'value: 5.414'
x-amz-apigw-id:
- fXzUdE5-CYcFjcQ=
x-amzn-Remapped-Connection:
- keep-alive
x-amzn-Remapped-Content-Length:
- '235'
x-amzn-Remapped-Date:
- Thu, 26 Jan 2023 22:31:49 GMT
x-amzn-Remapped-Server:
- nginx/1.22.1
x-amzn-RequestId:
- d6df16fc-7de4-491c-8355-750fea51aa84
status:
code: 201
message: Created
version: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
interactions:
- request:
body: '{"curp": null, "account_number": null, "names": null, "first_surname":
null, "second_surname": null}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- DUMMY
Connection:
- keep-alive
Content-Length:
- '100'
Content-Type:
- application/json
User-Agent:
- cuenca-python/0.15.8.dev2
X-Cuenca-Api-Version:
- '2020-03-19'
method: POST
uri: https://sandbox.cuenca.com/user_lists_validations
response:
body:
string: '{"error":"There is an error with the inputs"}'
headers:
Connection:
- keep-alive
Content-Length:
- '45'
Content-Type:
- application/json
Date:
- Thu, 26 Jan 2023 22:34:19 GMT
x-amz-apigw-id:
- fXzszEKAiYcFpjA=
x-amzn-Remapped-Connection:
- keep-alive
x-amzn-Remapped-Content-Length:
- '45'
x-amzn-Remapped-Date:
- Thu, 26 Jan 2023 22:34:19 GMT
x-amzn-Remapped-Server:
- nginx/1.22.1
x-amzn-RequestId:
- 7c91e271-c8ab-4fd7-a2c9-b7ab66f48daf
status:
code: 400
message: Bad Request
version: 1
20 changes: 20 additions & 0 deletions tests/resources/test_user_lists_validation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest
from cuenca_validations.types import VerificationStatus

from cuenca.exc import CuencaResponseException
from cuenca.resources import UserListsValidation


@pytest.mark.vcr
def test_create_user_validation(user_lists_request):
user_validation = UserListsValidation.create(**user_lists_request)
assert user_validation.status == VerificationStatus.succeeded
assert user_validation.id


@pytest.mark.vcr
def test_create_user_validation_invalid_inputs():
with pytest.raises(CuencaResponseException) as exc:
UserListsValidation.create(**dict())
assert exc.status_code == 403
assert exc.json['error'] == 'There is an error with the inputs'