cuenca-validations 2.1.49.dev0__py3-none-any.whl → 2.1.50.dev0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -114,6 +114,7 @@ __all__ = [
114
114
  'TransferQuery',
115
115
  'TransferRequest',
116
116
  'UpdateTransferOrderRequest',
117
+ 'UpdateTransferOrderStatus',
117
118
  'UpdateTransferRequest',
118
119
  'UserCardNotification',
119
120
  'UserCredentialRequest',
@@ -191,6 +192,7 @@ from .enums import (
191
192
  TransactionStatus,
192
193
  TransferNetwork,
193
194
  TransferOrderStatus,
195
+ UpdateTransferOrderStatus,
194
196
  UserCardNotification,
195
197
  UserStatus,
196
198
  UserType,
@@ -768,3 +768,8 @@ class TransferOrderStatus(str, Enum):
768
768
  authorized = 'authorized'
769
769
  rejected = 'rejected'
770
770
  expired = 'expired'
771
+
772
+
773
+ class UpdateTransferOrderStatus(str, Enum):
774
+ authorized = 'authorized'
775
+ rejected = 'rejected'
@@ -1,5 +1,5 @@
1
1
  import datetime as dt
2
- from typing import Annotated, Any, Literal, Optional, Union
2
+ from typing import Annotated, Any, Optional, Union
3
3
 
4
4
  from clabe import BANK_NAMES, Clabe
5
5
  from pydantic import (
@@ -50,7 +50,7 @@ from ..types.enums import (
50
50
  TrackDataMethod,
51
51
  TransactionStatus,
52
52
  TransactionTokenValidationStatus,
53
- TransferOrderStatus,
53
+ UpdateTransferOrderStatus,
54
54
  UserCardNotification,
55
55
  UserStatus,
56
56
  VerificationStatus,
@@ -1042,7 +1042,7 @@ class TransferOrderLineRequest(BaseRequest):
1042
1042
 
1043
1043
  class TransferOrderRequest(BaseRequest):
1044
1044
  idempotency_key: str
1045
- legal_person_id: Optional[str] = None
1045
+ legal_person_id: str
1046
1046
  items: list[TransferOrderLineRequest]
1047
1047
 
1048
1048
  model_config = ConfigDict(
@@ -1070,9 +1070,7 @@ class TransferOrderRequest(BaseRequest):
1070
1070
 
1071
1071
 
1072
1072
  class UpdateTransferOrderRequest(BaseRequest):
1073
- status: Literal[
1074
- TransferOrderStatus.authorized, TransferOrderStatus.rejected
1075
- ]
1073
+ status: UpdateTransferOrderStatus
1076
1074
  rejection_reason: Optional[str] = None
1077
1075
 
1078
1076
  model_config = ConfigDict(
@@ -1089,7 +1087,7 @@ class UpdateTransferOrderRequest(BaseRequest):
1089
1087
 
1090
1088
  @model_validator(mode='after')
1091
1089
  def validate_rejection_reason(self) -> 'UpdateTransferOrderRequest':
1092
- if self.status is TransferOrderStatus.rejected:
1090
+ if self.status is UpdateTransferOrderStatus.rejected:
1093
1091
  if (
1094
1092
  self.rejection_reason is None
1095
1093
  or not self.rejection_reason.strip()
@@ -1 +1 @@
1
- __version__ = '2.1.49.dev0'
1
+ __version__ = '2.1.50.dev0'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cuenca_validations
3
- Version: 2.1.49.dev0
3
+ Version: 2.1.50.dev0
4
4
  Summary: Cuenca common validations
5
5
  Home-page: https://github.com/cuenca-mx/cuenca-validations
6
6
  Author: Cuenca
@@ -4,27 +4,27 @@ cuenca_validations/errors.py,sha256=OtM8EgiKqYdz9Hn66AbBO96orL1or7efkyt0vh0Zxbs,
4
4
  cuenca_validations/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  cuenca_validations/typing.py,sha256=1QCu81IbVZZpyInjyeAuO-nF36gpT5Gi4o6V9PozuOU,204
6
6
  cuenca_validations/validators.py,sha256=zXSnU5-EMbQZBD-PfFXgP4Z6G7cm7KFDWXB7Nie6WUk,2682
7
- cuenca_validations/version.py,sha256=E1OKARtICq_n0Q4ukZ9yaw-H6GS0VhkKcaXf2C4kIGg,28
8
- cuenca_validations/types/__init__.py,sha256=M657giDGa3sejskWMPIAfCXJHDgbh4p9J9BnheKJR-A,6711
7
+ cuenca_validations/version.py,sha256=x45bT_ftEGYO5jfeEfTF7N5RSQsa2FHic_eeg9pqCQg,28
8
+ cuenca_validations/types/__init__.py,sha256=YCuHWRRCr1Ilmf8VVAr16Jj4e6WYdshDSMQuugd-cXQ,6775
9
9
  cuenca_validations/types/card.py,sha256=UGzz8NTFAverUmdUKAK1oGHnOnjSNTpIRUm93vKSSGY,1295
10
- cuenca_validations/types/enums.py,sha256=If8N4-AbM9daHmnH6txmBb9AqN0Ey7gi3jmkOZOIDAU,21104
10
+ cuenca_validations/types/enums.py,sha256=dR24uPDVh_uD4jehYf_7GaEKXHxypWNNuNTfj8kj3B4,21206
11
11
  cuenca_validations/types/files.py,sha256=2CszbwF9ytXV9suFFwyDjYG4XxY8UhCjRw3HttVXXNw,269
12
12
  cuenca_validations/types/general.py,sha256=eYFYwyx_a4_J480GYpqW3DFbZabDFcUjvLRMQbShIUc,5622
13
13
  cuenca_validations/types/helpers.py,sha256=4veeLZbugHHqZk0ezSim978VhH6Vq8XTrEhe1eE_r3A,1531
14
14
  cuenca_validations/types/identities.py,sha256=j2xxh3UYHJe6IbAwr9yNXJkebTth_-g3SUmHeiPez8M,5513
15
15
  cuenca_validations/types/morals.py,sha256=davabh5hAnFVQyM7-yCyDaT5ewXnm0cr1BtqDIwzkX8,1833
16
16
  cuenca_validations/types/queries.py,sha256=yJZGW3p6uWGaBm6mjDp7KBgg7oLh0CUlAJeeVLRzowk,6134
17
- cuenca_validations/types/requests.py,sha256=26YyfGHh1egdjAHUWTDjTtelXARWKNPB6npPHkW1Tcg,32336
18
- cuenca_validations-2.1.49.dev0.dist-info/licenses/LICENSE,sha256=wR76FmxBbfnQpwELkkE5iMF8sFIafEMgXLTE4N4WPTc,1063
17
+ cuenca_validations/types/requests.py,sha256=GD9jRpVOvjVNbXWd-TL4D3gsWEuAuGNAnfOK1Mm1-EE,32264
18
+ cuenca_validations-2.1.50.dev0.dist-info/licenses/LICENSE,sha256=wR76FmxBbfnQpwELkkE5iMF8sFIafEMgXLTE4N4WPTc,1063
19
19
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  tests/test_card.py,sha256=QAfRz7e11gWICPnFJZ2tiYgUsFV3C9TwzJXrDnDNXFw,1202
21
21
  tests/test_errors.py,sha256=ixiIgEuBuzfsL5p4uCFdF32XqFRtTPF6EVhGJ0keOrI,930
22
22
  tests/test_helpers.py,sha256=fx2R7y6oQO8XeQzevJe826NuHkBgvtznZicomchB3Gg,899
23
- tests/test_requests.py,sha256=NlXAvKDLyVy0tYDUHy3oNkxeX1KcA-dfyqwftddHWBo,10627
23
+ tests/test_requests.py,sha256=Av8P2npaRi49LCjCbCMFcT0wlgOtaM28V949sJKpJ60,10370
24
24
  tests/test_statement.py,sha256=IOE0rRRBgBZSJv_FLaETEyn5NzzXKMNTqgjv99GX-68,1436
25
25
  tests/test_types.py,sha256=rPjqPGfPU73MSdbeJpoW_ai5TAO25hWSnQAt_H7ZIeI,23055
26
26
  tests/test_validators.py,sha256=Jjr9gWTT4cRntGiKvQK4fncqx3JkEuTWkKm1VqpRHTs,1829
27
- cuenca_validations-2.1.49.dev0.dist-info/METADATA,sha256=7CzNDGl4cHPMNcq-p0u36AMzFYj2tFFmM34sc-pfn_E,1600
28
- cuenca_validations-2.1.49.dev0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
29
- cuenca_validations-2.1.49.dev0.dist-info/top_level.txt,sha256=4233xdOs2HtuT-GFRjcDcwK0IwdwvWdczOtk0fPB6Gw,25
30
- cuenca_validations-2.1.49.dev0.dist-info/RECORD,,
27
+ cuenca_validations-2.1.50.dev0.dist-info/METADATA,sha256=ZBDd1sB91hxxnfHTc7MGgQiGAtucTPUD164lFAqivi4,1600
28
+ cuenca_validations-2.1.50.dev0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
29
+ cuenca_validations-2.1.50.dev0.dist-info/top_level.txt,sha256=4233xdOs2HtuT-GFRjcDcwK0IwdwvWdczOtk0fPB6Gw,25
30
+ cuenca_validations-2.1.50.dev0.dist-info/RECORD,,
tests/test_requests.py CHANGED
@@ -5,7 +5,7 @@ from pydantic_extra_types.phone_numbers import PhoneNumber
5
5
  from cuenca_validations.types.enums import (
6
6
  Country,
7
7
  OperatorRole,
8
- TransferOrderStatus,
8
+ UpdateTransferOrderStatus,
9
9
  VerificationType,
10
10
  )
11
11
  from cuenca_validations.types.queries import OperatorQuery
@@ -245,49 +245,59 @@ def test_transfer_order_request_shape() -> None:
245
245
  'descriptor': 'Mezcal',
246
246
  }
247
247
  single = TransferOrderRequest.model_validate(
248
- {'idempotency_key': 'single', 'items': [line]}
248
+ {
249
+ 'idempotency_key': 'single',
250
+ 'legal_person_id': 'USWqY5cvkISJOxHyEKjAKf8w',
251
+ 'items': [line],
252
+ }
249
253
  )
254
+ assert single.legal_person_id == 'USWqY5cvkISJOxHyEKjAKf8w'
250
255
  assert single.items is not None
251
256
  assert len(single.items) == 1
252
257
  batch = TransferOrderRequest.model_validate(
253
- {'idempotency_key': 'batch', 'items': [line, line]}
258
+ {
259
+ 'idempotency_key': 'batch',
260
+ 'legal_person_id': 'USWqY5cvkISJOxHyEKjAKf8w',
261
+ 'items': [line, line],
262
+ }
254
263
  )
255
264
  assert batch.items is not None
256
265
  assert len(batch.items) == 2
257
266
 
258
267
  with pytest.raises(ValidationError, match='items must not be empty'):
259
268
  TransferOrderRequest.model_validate(
260
- {'idempotency_key': 'empty', 'items': []}
269
+ {
270
+ 'idempotency_key': 'empty',
271
+ 'legal_person_id': 'USWqY5cvkISJOxHyEKjAKf8w',
272
+ 'items': [],
273
+ }
261
274
  )
262
275
  with pytest.raises(ValidationError):
263
- TransferOrderRequest.model_validate({'idempotency_key': 'missing'})
264
-
265
-
266
- def test_update_transfer_order_request_authorized() -> None:
267
- req = UpdateTransferOrderRequest.model_validate({'status': 'authorized'})
268
- assert req.status is TransferOrderStatus.authorized
269
- assert req.rejection_reason is None
270
-
271
-
272
- def test_update_transfer_order_request_rejected() -> None:
273
- req = UpdateTransferOrderRequest.model_validate(
274
- {'status': 'rejected', 'rejection_reason': 'Monto incorrecto'}
275
- )
276
- assert req.status is TransferOrderStatus.rejected
277
- assert req.rejection_reason == 'Monto incorrecto'
276
+ TransferOrderRequest.model_validate(
277
+ {
278
+ 'idempotency_key': 'missing-items',
279
+ 'legal_person_id': 'USWqY5cvkISJOxHyEKjAKf8w',
280
+ }
281
+ )
282
+ with pytest.raises(ValidationError, match='legal_person_id'):
283
+ TransferOrderRequest.model_validate(
284
+ {'idempotency_key': 'missing-person', 'items': [line]}
285
+ )
278
286
 
279
287
 
280
- def test_update_transfer_order_request_rejected_requires_reason() -> None:
281
- with pytest.raises(ValidationError, match='rejection_reason is required'):
282
- UpdateTransferOrderRequest.model_validate({'status': 'rejected'})
283
- with pytest.raises(ValidationError, match='rejection_reason is required'):
284
- UpdateTransferOrderRequest.model_validate(
285
- {'status': 'rejected', 'rejection_reason': ''}
286
- )
288
+ @pytest.mark.parametrize(
289
+ 'payload',
290
+ [
291
+ {'status': 'rejected'},
292
+ {'status': 'rejected', 'rejection_reason': ''},
293
+ {'status': 'rejected', 'rejection_reason': ' '},
294
+ ],
295
+ )
296
+ def test_update_transfer_order_request_rejected_requires_reason(
297
+ payload: dict,
298
+ ) -> None:
287
299
  with pytest.raises(ValidationError, match='rejection_reason is required'):
288
- UpdateTransferOrderRequest.model_validate(
289
- {'status': 'rejected', 'rejection_reason': ' '}
290
- )
300
+ UpdateTransferOrderRequest.model_validate(payload)
291
301
 
292
302
 
293
303
  def test_update_transfer_order_request_authorized_forbids_reason() -> None:
@@ -300,18 +310,18 @@ def test_update_transfer_order_request_authorized_forbids_reason() -> None:
300
310
  )
301
311
 
302
312
 
303
- def test_update_transfer_order_request_rejects_invalid_status() -> None:
304
- with pytest.raises(ValidationError):
305
- UpdateTransferOrderRequest.model_validate({'status': 'created'})
306
- with pytest.raises(ValidationError):
307
- UpdateTransferOrderRequest.model_validate({'status': 'expired'})
308
- with pytest.raises(ValidationError):
309
- UpdateTransferOrderRequest.model_validate({})
310
-
311
-
312
- def test_update_transfer_order_request_forbids_extra() -> None:
313
- with pytest.raises(ValidationError) as ex:
314
- UpdateTransferOrderRequest.model_validate(
315
- {'status': 'authorized', 'operator_id': 'OP123'}
316
- )
317
- assert 'Extra inputs are not permitted' in str(ex.value)
313
+ @pytest.mark.parametrize(
314
+ 'payload, status',
315
+ [
316
+ ({'status': 'authorized'}, UpdateTransferOrderStatus.authorized),
317
+ (
318
+ {'status': 'rejected', 'rejection_reason': 'Monto incorrecto'},
319
+ UpdateTransferOrderStatus.rejected,
320
+ ),
321
+ ],
322
+ )
323
+ def test_update_transfer_order_request_valid(
324
+ payload: dict, status: UpdateTransferOrderStatus
325
+ ) -> None:
326
+ req = UpdateTransferOrderRequest.model_validate(payload)
327
+ assert req.status is status