FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-validators/tests/test_encoding.py at master · sysfce2/python-validators · GitHub
sysfce2
python-validators
Repository navigation
Code
Pull requests
1
(1)
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
python-validators
/
tests
/
test_encoding.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
117 lines (92 loc) · 2.82 KB
Breadcrumbs
python-validators
/
tests
/
test_encoding.py
Copy path
File metadata and controls
117 lines (92 loc) · 2.82 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
"""Test Encodings."""
# external
import
pytest
# local
from
validators
import
ValidationError
,
base16
,
base32
,
base58
,
base64
# ==> base16 <== #
@
pytest
.
mark
.
parametrize
(
"value"
,
[
"a3f4b2"
,
"01ef"
,
"abcdef0123456789"
,
"1234567890abcdef"
,
"1a2b3c"
,
"abcdef"
,
"000102030405060708090A0B0C0D0E0F"
,
],
)
def
test_returns_true_on_valid_base16
(
value
:
str
):
"""Test returns true on valid base16."""
assert
base16
(
value
)
@
pytest
.
mark
.
parametrize
(
"value"
,
[
"12345g"
,
"hello world"
,
"1234567890abcdeg"
,
"GHIJKL"
,
"12345G"
,
"!@#$%^"
,
"1a2h3c"
,
"a3f4Z1"
],
)
def
test_returns_failed_validation_on_invalid_base16
(
value
:
str
):
"""Test returns failed validation on invalid base16."""
assert
isinstance
(
base16
(
value
),
ValidationError
)
# ==> base32 <== #
@
pytest
.
mark
.
parametrize
(
"value"
,
[
"JBSWY3DPEHPK3PXP"
,
"MFRGGZDFMZTWQ2LK"
,
"MZXW6YTBOI======"
,
"MFZWIZLTOQ======"
,
"GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ"
,
"MFRGGZDFMZTWQ2LKNNWG23Q="
,
],
)
def
test_returns_true_on_valid_base32
(
value
:
str
):
"""Test returns true on valid base32."""
assert
base32
(
value
)
@
pytest
.
mark
.
parametrize
(
"value"
,
[
"ThisIsNotBase32!"
,
"12345!"
,
"Any==invalid=base32="
,
"MzXW6yTBOI======"
,
"JBSWY8DPEHPK9PXP"
,
"MfZW3zLT9Q======"
,
],
)
def
test_returns_failed_validation_on_invalid_base32
(
value
:
str
):
"""Test returns failed validation on invalid base32."""
assert
isinstance
(
base32
(
value
),
ValidationError
)
# ==> base58 <== #
@
pytest
.
mark
.
parametrize
(
"value"
,
[
"cUSECaVvAiV3srWbFRvVPzm5YzcXJwPSwZfE7veYPHoXmR9h6YMQ"
,
"18KToMF5ckjXBYt2HAj77qsG3GPeej3PZn"
,
"n4FFXRNNEW1aA2WPscSuzHTCjzjs4TVE2Z"
,
"38XzQ9dPGb1uqbZsjPtUajp7omy8aefjqj"
,
],
)
def
test_returns_true_on_valid_base58
(
value
:
str
):
"""Test returns true on valid base58."""
assert
base58
(
value
)
@
pytest
.
mark
.
parametrize
(
"value"
,
[
"ThisIsAReallyLongStringThatIsDefinitelyNotBase58Encoded"
,
"abcABC!@#"
,
"InvalidBase58!"
],
)
def
test_returns_failed_validation_on_invalid_base58
(
value
:
str
):
"""Test returns failed validation on invalid base58."""
assert
isinstance
(
base58
(
value
),
ValidationError
)
# ==> base64 <== #
@
pytest
.
mark
.
parametrize
(
"value"
,
[
"SGVsbG8gV29ybGQ="
,
"U29tZSBkYXRhIHN0cmluZw=="
,
"YW55IGNhcm5hbCBwbGVhcw=="
],
)
def
test_returns_true_on_valid_base64
(
value
:
str
):
"""Test returns true on valid base64."""
assert
base64
(
value
)
@
pytest
.
mark
.
parametrize
(
"value"
,
[
"SGVsbG8gV29ybGQ"
,
"U29tZSBkYXRhIHN0cmluZw"
,
"YW55IGNhcm5hbCBwbGVhc"
],
)
def
test_returns_failed_validation_on_invalid_base64
(
value
:
str
):
"""Test returns failed validation on invalid base64."""
assert
isinstance
(
base64
(
value
),
ValidationError
)
Back
|
FazBrowse Home
|
New Git URL