Some checks failed
Test before pr merge / test-lint (pull_request) Failing after 9s
28 lines
698 B
Python
28 lines
698 B
Python
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??")
|