2020-02-03 17:25:54 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from benedict.serializers import AbstractSerializer
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
|
|
class abstract_serializer_test_case(unittest.TestCase):
|
2022-02-13 10:35:43 +00:00
|
|
|
"""
|
|
|
|
This class describes an abstract serializer test case.
|
|
|
|
"""
|
2020-02-03 17:25:54 +00:00
|
|
|
|
|
|
|
def test_decode_abstract(self):
|
|
|
|
s = AbstractSerializer()
|
|
|
|
with self.assertRaises(NotImplementedError):
|
2022-02-13 10:35:43 +00:00
|
|
|
s.decode("")
|
2020-02-03 17:25:54 +00:00
|
|
|
|
|
|
|
def test_encode_abstract(self):
|
|
|
|
s = AbstractSerializer()
|
|
|
|
with self.assertRaises(NotImplementedError):
|
|
|
|
s.encode({})
|
2020-02-19 14:16:23 +00:00
|
|
|
|
|
|
|
def test_inheritance(self):
|
|
|
|
class ConcreteSerializer(AbstractSerializer):
|
|
|
|
@staticmethod
|
|
|
|
def encode(d):
|
2022-02-13 10:35:43 +00:00
|
|
|
return ""
|
|
|
|
|
2020-02-19 14:16:23 +00:00
|
|
|
s = ConcreteSerializer()
|
2022-02-13 10:35:43 +00:00
|
|
|
self.assertEqual(s.encode({}), "")
|
2020-02-19 14:16:23 +00:00
|
|
|
with self.assertRaises(NotImplementedError):
|
2022-02-13 10:35:43 +00:00
|
|
|
s.decode("")
|