Added first tests #191
Some checks failed
Test before pr merge / test-lint (pull_request) Failing after 9s
Some checks failed
Test before pr merge / test-lint (pull_request) Failing after 9s
This commit is contained in:
27
test/core/utils/base64_test.py
Normal file
27
test/core/utils/base64_test.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from cpl.core.utils.base64 import Base64
|
||||
|
||||
|
||||
def test_encode():
|
||||
assert Base64.encode("hello world") == "aGVsbG8gd29ybGQ="
|
||||
s = "foobar"
|
||||
assert Base64.encode(s) and isinstance(Base64.encode(s), str)
|
||||
|
||||
|
||||
def test_decode():
|
||||
out = Base64.decode("aGVsbG8gd29ybGQ=")
|
||||
if isinstance(out, bytes):
|
||||
out = out.decode("utf-8")
|
||||
assert out == "hello world"
|
||||
|
||||
orig = "äöü߀"
|
||||
enc = Base64.encode(orig)
|
||||
dec = Base64.decode(enc)
|
||||
if isinstance(dec, bytes):
|
||||
dec = dec.decode("utf-8")
|
||||
assert dec == orig
|
||||
|
||||
|
||||
def test_is_b64():
|
||||
assert Base64.is_b64("Zm9vYmFy") # "foobar"
|
||||
assert Base64.is_b64("Zm8=") # "fo"
|
||||
assert not Base64.is_b64("not_base64??")
|
||||
Reference in New Issue
Block a user