How to use the aiocache.serializers.MsgPackSerializer function in aiocache

To help you get started, we’ve selected a few aiocache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github argaen / aiocache / tests / ut / test_serializers.py View on Github external
def test_init(self):
        serializer = MsgPackSerializer()
        assert isinstance(serializer, BaseSerializer)
        assert serializer.DEFAULT_ENCODING == "utf-8"
        assert serializer.encoding == "utf-8"
github argaen / aiocache / tests / ut / test_serializers.py View on Github external
def test_loads(self):
        assert MsgPackSerializer().loads(b"\xa2hi") == "hi"
github argaen / aiocache / tests / ut / test_serializers.py View on Github external
def test_init_fails_if_msgpack_not_installed(self):
        with mock.patch("aiocache.serializers.serializers.msgpack", None):
            with pytest.raises(RuntimeError):
                MsgPackSerializer()
            assert JsonSerializer(), "Other serializers should still initialize"
github argaen / aiocache / tests / ut / test_serializers.py View on Github external
def test_init_use_list(self):
        serializer = MsgPackSerializer(use_list=True)
        assert serializer.use_list is True
github argaen / aiocache / tests / ut / test_serializers.py View on Github external
def test_set_types(self, obj):
        serializer = MsgPackSerializer()
        assert serializer.loads(serializer.dumps(obj)) == obj
github argaen / aiocache / tests / ut / test_serializers.py View on Github external
def test_dumps(self):
        assert MsgPackSerializer().dumps("hi") == b"\xa2hi"
github argaen / aiocache / tests / ut / test_serializers.py View on Github external
def test_dumps_and_loads_dict(self):
        serializer = MsgPackSerializer()
        d = {"a": [1, 2, ("1", 2)], "b": {"b": 1, "c": [1, 2]}}
        assert serializer.loads(serializer.dumps(d)) == {
            "a": [1, 2, ["1", 2]],
            "b": {"b": 1, "c": [1, 2]},
        }
github argaen / aiocache / tests / ut / test_serializers.py View on Github external
def test_loads_with_none(self):
        assert MsgPackSerializer().loads(None) is None
github argaen / aiocache / tests / ut / test_serializers.py View on Github external
def test_dumps_and_loads_tuple(self):
        serializer = MsgPackSerializer()
        assert serializer.loads(serializer.dumps(Dummy(1, 2))) == [1, 2]
github argaen / aiocache / tests / ut / test_serializers.py View on Github external
def test_dumps_with_none(self):
        assert isinstance(MsgPackSerializer().dumps(None), bytes)