def test_missing_serializer(self): from pyramid_caching.serializers import SerializationError utility = SerializerUtility(self.config.registry) class UnknownType: pass with self.assertRaises(SerializationError): utility.dumps(UnknownType())
def test_query_serializer(self): utility = SerializerUtility(self.config.registry) utility.register_serialization_adapter(str, DummyAdapter) data = utility.dumps("object") data = pickle.loads(data) self.assertEqual(data['payload'], "OBJECT")
def test_encode_payload(self): utility = SerializerUtility(DummyRegistry()) data = utility.dumps("object", adapter=DummyAdapter()) data = pickle.loads(data) self.assertEqual(data['payload'], "OBJECT")
def test_encode_meta_format_version(self): utility = SerializerUtility(DummyRegistry()) data = utility.dumps("object", adapter=DummyAdapter()) data = pickle.loads(data) self.assertEqual(data['version'], SERIALIZER_META_VERSION)
def test_encode_serializer_type(self): utility = SerializerUtility(DummyRegistry()) data = utility.dumps("object", adapter=DummyAdapter()) data = pickle.loads(data) self.assertEqual(data['type'], "dummy")