fix: PickleCoder and add tests for it.

This commit is contained in:
Ivan Moiseev
2022-11-05 13:45:16 +04:00
parent 73f000a565
commit cb9fe5c065
2 changed files with 29 additions and 6 deletions

22
tests/test_codecs.py Normal file
View File

@@ -0,0 +1,22 @@
from typing import Any
import pytest
from fastapi_cache.coder import PickleCoder
@pytest.mark.parametrize(
"value",
[
1,
"some_string",
(1, 2),
[1, 2, 3],
{"some_key": 1, "other_key": 2},
],
)
def test_pickle_coder(value: Any) -> None:
encoded_value = PickleCoder.encode(value)
assert isinstance(encoded_value, str)
decoded_value = PickleCoder.decode(encoded_value)
assert decoded_value == value