pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python-validators/validators/commit/7efc22301522674ef1ec4e20c08eefb123a09068

link crossorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-b40ec823a1a6a1af.css" /> patch: adds `encoding` tests and docs · python-validators/validators@7efc223 · GitHub
Skip to content

Commit 7efc223

Browse files
committed
patch: adds encoding tests and docs
1 parent 55e40ac commit 7efc223

6 files changed

Lines changed: 64 additions & 4 deletions

File tree

docs/api/encoding.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# encoding
2+
3+
::: validators.encoding.base58
4+
::: validators.encoding.base64

docs/api/encoding.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
encoding
2+
--------
3+
4+
.. module:: validators.encoding
5+
.. autofunction:: base58
6+
.. autofunction:: base64

docs/api/hashes.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# hashes
22

3-
::: validators.hashes.base58
4-
::: validators.hashes.base64
53
::: validators.hashes.md5
64
::: validators.hashes.sha1
75
::: validators.hashes.sha224

docs/api/hashes.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ hashes
22
------
33

44
.. module:: validators.hashes
5-
.. autofunction:: base58
6-
.. autofunction:: base64
75
.. autofunction:: md5
86
.. autofunction:: sha1
97
.. autofunction:: sha224

mkdocs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ nav:
7676
- api/cron.md
7777
- api/domain.md
7878
- api/email.md
79+
- api/encoding.md
7980
- api/hashes.md
8081
- api/hostname.md
8182
- api/i18n.md

tests/test_encoding.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""Test Encodings."""
2+
3+
# external
4+
import pytest
5+
6+
# local
7+
from validators import ValidationError, base58, base64
8+
9+
# ==> base58 <== #
10+
11+
12+
@pytest.mark.parametrize(
13+
"value",
14+
[
15+
"cUSECaVvAiV3srWbFRvVPzm5YzcXJwPSwZfE7veYPHoXmR9h6YMQ",
16+
"18KToMF5ckjXBYt2HAj77qsG3GPeej3PZn",
17+
"n4FFXRNNEW1aA2WPscSuzHTCjzjs4TVE2Z",
18+
"38XzQ9dPGb1uqbZsjPtUajp7omy8aefjqj",
19+
],
20+
)
21+
def test_returns_true_on_valid_base58(value: str):
22+
"""Test returns true on valid base58."""
23+
assert base58(value)
24+
25+
26+
@pytest.mark.parametrize(
27+
"value",
28+
["ThisIsAReallyLongStringThatIsDefinitelyNotBase58Encoded", "abcABC!@#", "InvalidBase58!"],
29+
)
30+
def test_returns_failed_validation_on_invalid_base58(value: str):
31+
"""Test returns failed validation on invalid base58."""
32+
assert isinstance(base58(value), ValidationError)
33+
34+
35+
# ==> base64 <== #
36+
37+
38+
@pytest.mark.parametrize(
39+
"value",
40+
["SGVsbG8gV29ybGQ=", "U29tZSBkYXRhIHN0cmluZw==", "YW55IGNhcm5hbCBwbGVhcw=="],
41+
)
42+
def test_returns_true_on_valid_base64(value: str):
43+
"""Test returns true on valid base64."""
44+
assert base64(value)
45+
46+
47+
@pytest.mark.parametrize(
48+
"value",
49+
["SGVsbG8gV29ybGQ", "U29tZSBkYXRhIHN0cmluZw", "YW55IGNhcm5hbCBwbGVhc"],
50+
)
51+
def test_returns_failed_validation_on_invalid_base64(value: str):
52+
"""Test returns failed validation on invalid base64."""
53+
assert isinstance(base64(value), ValidationError)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy