cuenca-validations 2.0.1__py3-none-any.whl → 2.0.2.dev1__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.
@@ -103,6 +103,7 @@ __all__ = [
103
103
  'WebhookEvent',
104
104
  'digits',
105
105
  'get_state_name',
106
+ 'uuid_field',
106
107
  ]
107
108
 
108
109
  from .card import StrictPaymentCardNumber
@@ -156,6 +157,7 @@ from .general import (
156
157
  digits,
157
158
  get_state_name,
158
159
  )
160
+ from .helpers import uuid_field
159
161
  from .identities import (
160
162
  Address,
161
163
  Beneficiary,
@@ -0,0 +1,9 @@
1
+ import uuid
2
+ from base64 import urlsafe_b64encode
3
+
4
+
5
+ def uuid_field(prefix: str = ''):
6
+ def base64_uuid_func() -> str:
7
+ return prefix + urlsafe_b64encode(uuid.uuid4().bytes).decode()[:-2]
8
+
9
+ return base64_uuid_func
@@ -1 +1 @@
1
- __version__ = '2.0.1'
1
+ __version__ = '2.0.2.dev1'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: cuenca_validations
3
- Version: 2.0.1
3
+ Version: 2.0.2.dev1
4
4
  Summary: Cuenca common validations
5
5
  Home-page: https://github.com/cuenca-mx/cuenca-validations
6
6
  Author: Cuenca
@@ -4,12 +4,13 @@ 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=wzwLnJ4wHggZvqp3mearbFkzvDERGeTNvJkuofQnuMc,1484
7
- cuenca_validations/version.py,sha256=HVx0XJJ9OYFWBBPBCUFYb8Nm43ChPg9GZLh_dkxh9qI,22
8
- cuenca_validations/types/__init__.py,sha256=gGOQcmGyUaYB3zANSlCqxtDVw3TCYhVKd73GIfsxUFs,4701
7
+ cuenca_validations/version.py,sha256=x9KFcj-g4seFaeT0HfpMSsg_CQWCiMiyF7Nn7l_rjDY,27
8
+ cuenca_validations/types/__init__.py,sha256=4xjEu92oblZkz0wZw9jb_ZK9L_lOkK0_4pi5PYS2LsA,4751
9
9
  cuenca_validations/types/card.py,sha256=UGzz8NTFAverUmdUKAK1oGHnOnjSNTpIRUm93vKSSGY,1295
10
10
  cuenca_validations/types/enums.py,sha256=1ACr7I1iknXfm49y0YeP2sY1ZdZfreFC5cV4_6OJCw8,18825
11
11
  cuenca_validations/types/files.py,sha256=8-8vPKywxdZYGBIZ5tAQcK1EHtbiqCOMNy89OORzB_Y,225
12
12
  cuenca_validations/types/general.py,sha256=Dc_QlSJxgFo7Y9V8rWQ6u0jFKSRsMZP1V3OaeaL5SU8,1904
13
+ cuenca_validations/types/helpers.py,sha256=5xsLahmzFj9JhjCJLoBWxeixtc5dZlkx3rkG-_AIkec,225
13
14
  cuenca_validations/types/identities.py,sha256=5hOLeA05HUlTZ7UWfpPDHbh2Kc2xSezp4ETSbpRsMDE,4735
14
15
  cuenca_validations/types/morals.py,sha256=m8kAedevmwfSPTA9GYe03l7pkgipynwYgKfejyVtnuI,1813
15
16
  cuenca_validations/types/queries.py,sha256=KCRx0sPzWDtDDbZysmFGVgANgfqil17EITWaG7tGQ-A,4700
@@ -17,10 +18,11 @@ cuenca_validations/types/requests.py,sha256=a5bVbe_idOzirlOHRuraRLzVxk-ImRPLsmE5
17
18
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
19
  tests/test_card.py,sha256=QAfRz7e11gWICPnFJZ2tiYgUsFV3C9TwzJXrDnDNXFw,1202
19
20
  tests/test_errors.py,sha256=ixiIgEuBuzfsL5p4uCFdF32XqFRtTPF6EVhGJ0keOrI,930
21
+ tests/test_helpers.py,sha256=ubzpi1UXCryLQdgsT_Zm2IX-XE_4L0dnHnhLwH06xK8,748
20
22
  tests/test_statement.py,sha256=IOE0rRRBgBZSJv_FLaETEyn5NzzXKMNTqgjv99GX-68,1436
21
23
  tests/test_types.py,sha256=oPGh1BCi9DaU99gHhzi_0XBkWvjA7fCUk3oI8HYigtA,15732
22
- cuenca_validations-2.0.1.dist-info/LICENSE,sha256=wR76FmxBbfnQpwELkkE5iMF8sFIafEMgXLTE4N4WPTc,1063
23
- cuenca_validations-2.0.1.dist-info/METADATA,sha256=6etSJ_H755Ydco-d2PXdasnVt3zUIn44W-FsIoJZWL8,1572
24
- cuenca_validations-2.0.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
25
- cuenca_validations-2.0.1.dist-info/top_level.txt,sha256=4233xdOs2HtuT-GFRjcDcwK0IwdwvWdczOtk0fPB6Gw,25
26
- cuenca_validations-2.0.1.dist-info/RECORD,,
24
+ cuenca_validations-2.0.2.dev1.dist-info/LICENSE,sha256=wR76FmxBbfnQpwELkkE5iMF8sFIafEMgXLTE4N4WPTc,1063
25
+ cuenca_validations-2.0.2.dev1.dist-info/METADATA,sha256=eCNP2lvw2jHjY53N2e7CCoW0RghjAEUlKrR2EFYIgSo,1577
26
+ cuenca_validations-2.0.2.dev1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
27
+ cuenca_validations-2.0.2.dev1.dist-info/top_level.txt,sha256=4233xdOs2HtuT-GFRjcDcwK0IwdwvWdczOtk0fPB6Gw,25
28
+ cuenca_validations-2.0.2.dev1.dist-info/RECORD,,
tests/test_helpers.py ADDED
@@ -0,0 +1,29 @@
1
+ from cuenca_validations.types import uuid_field
2
+
3
+
4
+ def test_uuid_field_without_prefix():
5
+ generator = uuid_field()
6
+ uuid_str = generator()
7
+ assert isinstance(uuid_str, str)
8
+ assert len(uuid_str) == 22
9
+ assert generator() != generator()
10
+
11
+
12
+ def test_uuid_field_with_prefix():
13
+ prefix = 'AK'
14
+ generator = uuid_field(prefix)
15
+ uuid_str = generator()
16
+ assert isinstance(uuid_str, str)
17
+ assert uuid_str.startswith(prefix)
18
+ assert len(uuid_str) == 22 + len(prefix)
19
+ assert generator() != generator()
20
+
21
+
22
+ def test_multiple_generators():
23
+ gen1 = uuid_field('CA')
24
+ gen2 = uuid_field('TR')
25
+ uuid1 = gen1()
26
+ uuid2 = gen2()
27
+ assert uuid1.startswith('CA')
28
+ assert uuid2.startswith('TR')
29
+ assert uuid1 != uuid2