cuenca-validations 2.1.16.dev10__py3-none-any.whl → 2.1.16.dev11__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.
@@ -704,7 +704,7 @@ class Profession(str, Enum):
704
704
  sistemas = 'sistemas'
705
705
  independiente = 'independiente'
706
706
  oficios = 'oficios'
707
- otros = 'otros'
707
+ otro = 'otro'
708
708
 
709
709
 
710
710
  class AccountUseType(str, Enum):
@@ -121,7 +121,7 @@ names_professions = {
121
121
  Profession.sistemas: 'Sistemas y Comunicaciones',
122
122
  Profession.independiente: 'Trabajador(a/e) Independiente',
123
123
  Profession.oficios: 'Oficios Varios',
124
- Profession.otros: 'Otros',
124
+ Profession.otro: 'Otro',
125
125
  }
126
126
 
127
127
 
@@ -487,6 +487,13 @@ class UserRequest(BaseModel):
487
487
  validate_age_requirement(curp)
488
488
  return curp
489
489
 
490
+ @field_validator('profession')
491
+ @classmethod
492
+ def validate_profession(cls, profession: Profession) -> Profession:
493
+ if profession == Profession.otro:
494
+ raise ValueError('Profession "otro" is not allowed for this model')
495
+ return profession
496
+
490
497
 
491
498
  class UserUpdateRequest(BaseModel):
492
499
  profession: Optional[Profession] = None
@@ -517,6 +524,13 @@ class UserUpdateRequest(BaseModel):
517
524
  raise ValueError('The total percentage should be 100%')
518
525
  return beneficiaries
519
526
 
527
+ @field_validator('profession')
528
+ @classmethod
529
+ def validate_profession(cls, profession: Profession) -> Profession:
530
+ if profession == Profession.otro:
531
+ raise ValueError('Profession "otro" is not allowed for this model')
532
+ return profession
533
+
520
534
 
521
535
  class UserLoginRequest(BaseRequest):
522
536
  password: Annotated[
@@ -1 +1 @@
1
- __version__ = '2.1.16.dev10'
1
+ __version__ = '2.1.16.dev11'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cuenca_validations
3
- Version: 2.1.16.dev10
3
+ Version: 2.1.16.dev11
4
4
  Summary: Cuenca common validations
5
5
  Home-page: https://github.com/cuenca-mx/cuenca-validations
6
6
  Author: Cuenca
@@ -4,26 +4,26 @@ 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=mYJDXxJVokl5jZIA4FYn8wkaMUnOxAH54t1Pfg_0kmQ,1190
7
- cuenca_validations/version.py,sha256=epToQJwFOxPSE_YZMBlIIdufpD9Ngja5yOlyfVRe-ZU,29
7
+ cuenca_validations/version.py,sha256=bxGMm5XXUsyFEXfPIpYbnuBcZ_6fYlSDtApDKaeiVCI,29
8
8
  cuenca_validations/types/__init__.py,sha256=CIfqLhBxUMX5YAI-FvX9pnHB233BivGJZj1lFNddx-k,5415
9
9
  cuenca_validations/types/card.py,sha256=UGzz8NTFAverUmdUKAK1oGHnOnjSNTpIRUm93vKSSGY,1295
10
- cuenca_validations/types/enums.py,sha256=u2CxOHSnVbwlfN3Ys0cXU1l2vw_zDNo13QU2vVvuIRU,20365
10
+ cuenca_validations/types/enums.py,sha256=jFHLmHSGhvM69LrQ7Yon9FIC9ZEZBbDrbeoyIo_hs3E,20363
11
11
  cuenca_validations/types/files.py,sha256=2CszbwF9ytXV9suFFwyDjYG4XxY8UhCjRw3HttVXXNw,269
12
- cuenca_validations/types/general.py,sha256=phXGbEtAfN1Mw26rblYDiFGBwFnhf1tK12ekwhuKFNo,5452
12
+ cuenca_validations/types/general.py,sha256=XcoqEORNFXwsi5XP8_Zza4XuAF-bS2QrXBipKFiEhc4,5450
13
13
  cuenca_validations/types/helpers.py,sha256=XPiYVTLDtmBB5R1heWUy1c35zZMh7nh-BmS6rtwEltg,1379
14
14
  cuenca_validations/types/identities.py,sha256=1wkutHzL9Gpd9oAZdyiikNxWKe5iBVAQT3TabR6YG1o,5451
15
15
  cuenca_validations/types/morals.py,sha256=davabh5hAnFVQyM7-yCyDaT5ewXnm0cr1BtqDIwzkX8,1833
16
16
  cuenca_validations/types/queries.py,sha256=Pp7BAPk20hzImxb5EIiy3oI8S6AeCruU-NbQpOlrWVo,5146
17
- cuenca_validations/types/requests.py,sha256=IU0gbWxvs7QTcBfA1WsUqhm2RJPCXjytCy3jClAFp4A,21678
18
- cuenca_validations-2.1.16.dev10.dist-info/licenses/LICENSE,sha256=wR76FmxBbfnQpwELkkE5iMF8sFIafEMgXLTE4N4WPTc,1063
17
+ cuenca_validations/types/requests.py,sha256=eVoas88FWL8x4C5lSO0aNn0zhP-LgvwJbKE1AzfGOds,22224
18
+ cuenca_validations-2.1.16.dev11.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=ubzpi1UXCryLQdgsT_Zm2IX-XE_4L0dnHnhLwH06xK8,748
23
23
  tests/test_requests.py,sha256=HGKybPNlN-Vbf2Ew34csfMR5UzZdVPoX9J8eeD4yCiI,1095
24
24
  tests/test_statement.py,sha256=IOE0rRRBgBZSJv_FLaETEyn5NzzXKMNTqgjv99GX-68,1436
25
- tests/test_types.py,sha256=2CSwhYn5WDFBHQl2239FD9J7KlB2_Tt7RVqQUlFcwnI,20074
26
- cuenca_validations-2.1.16.dev10.dist-info/METADATA,sha256=TcM8AcoimaBQ82n7GL5wLBguZXh_MMylYn_6qmqTdvc,1601
27
- cuenca_validations-2.1.16.dev10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
28
- cuenca_validations-2.1.16.dev10.dist-info/top_level.txt,sha256=4233xdOs2HtuT-GFRjcDcwK0IwdwvWdczOtk0fPB6Gw,25
29
- cuenca_validations-2.1.16.dev10.dist-info/RECORD,,
25
+ tests/test_types.py,sha256=tq9YNF44fenQUJ6Fm6B46rLQHHtcTvfDGvcnTJLgueU,20777
26
+ cuenca_validations-2.1.16.dev11.dist-info/METADATA,sha256=Ixd580nQf64gfYlPR2wb3KEEftlnQgiRfAnletmZ3Gk,1601
27
+ cuenca_validations-2.1.16.dev11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
28
+ cuenca_validations-2.1.16.dev11.dist-info/top_level.txt,sha256=4233xdOs2HtuT-GFRjcDcwK0IwdwvWdczOtk0fPB6Gw,25
29
+ cuenca_validations-2.1.16.dev11.dist-info/RECORD,,
tests/test_types.py CHANGED
@@ -328,6 +328,23 @@ def test_user_request():
328
328
  assert UserRequest(**request).model_dump(exclude_none=True) == request
329
329
 
330
330
 
331
+ def test_user_request_invalid_profession():
332
+ request = dict(
333
+ curp='ABCD920604HDFSRN03',
334
+ profession=Profession.otro,
335
+ address=dict(
336
+ street='calle 1',
337
+ ext_number='2',
338
+ int_number='3',
339
+ postal_code_id='PC2ygq9j2bS9-9tsuVawzErA',
340
+ ),
341
+ phone_verification_id='VE12345678',
342
+ email_verification_id='VE0987654321',
343
+ )
344
+ with pytest.raises(ValidationError):
345
+ UserRequest(**request)
346
+
347
+
331
348
  @freeze_time('2022-01-01')
332
349
  def test_user_request_underage():
333
350
  request = dict(
@@ -419,6 +436,7 @@ def test_user_update_request():
419
436
  ),
420
437
  ],
421
438
  curp_document_uri='https://sandbox.cuenca.com/files/EF123',
439
+ profession=Profession.empleado,
422
440
  )
423
441
  update_req = UserUpdateRequest(**request)
424
442
  beneficiaries = [b.model_dump() for b in update_req.beneficiaries]
@@ -427,6 +445,7 @@ def test_user_update_request():
427
445
  update_req.curp_document_uri.unicode_string()
428
446
  == request['curp_document_uri']
429
447
  )
448
+ assert update_req.profession == Profession.empleado
430
449
 
431
450
  request['beneficiaries'] = [
432
451
  dict(
@@ -490,6 +509,10 @@ def test_user_update_request():
490
509
  )
491
510
  UserUpdateRequest(**kyc_request)
492
511
 
512
+ request['profession'] = Profession.otro
513
+ with pytest.raises(ValidationError) as v:
514
+ UserUpdateRequest(**request)
515
+
493
516
 
494
517
  def test_session_request():
495
518
  data = dict(