예제 #1
0
class JSONClientMixinTests(TestCase):
    def setUp(self):
        self.mixin = JSONClientMixin()

    def test_empty(self):
        original_data = None

        serialized_data = self.mixin.serialize(original_data)
        self.assertEqual(serialized_data, '')

        deserialized_data = self.mixin.deserialize(serialized_data)
        self.assertEqual(original_data, deserialized_data)

    def test_empty_string(self):
        original_data = ''

        serialized_data = self.mixin.serialize(original_data)
        self.assertEqual(serialized_data, '""')

        deserialized_data = self.mixin.deserialize(serialized_data)
        self.assertEqual(original_data, deserialized_data)

    def test_complex_data(self):
        original_data = {'a': ['b', 'c', 1, Decimal('2.3')]}

        serialized_data = self.mixin.serialize(original_data)
        self.assertEqual(serialized_data, '{"a": ["b", "c", 1, 2.3]}')

        deserialized_data = self.mixin.deserialize(serialized_data)
        self.assertEqual(original_data, deserialized_data)
예제 #2
0
class JSONClientMixinTests(TestCase):
    def setUp(self):
        self.mixin = JSONClientMixin()
    
    def test_empty(self):
        original_data = None
        
        serialized_data = self.mixin.serialize(original_data)
        self.assertEqual(serialized_data, '')
        
        deserialized_data = self.mixin.deserialize(serialized_data)
        self.assertEqual(original_data, deserialized_data)
    
    def test_empty_string(self):
        original_data = ''
        
        serialized_data = self.mixin.serialize(original_data)
        self.assertEqual(serialized_data, '""')
        
        deserialized_data = self.mixin.deserialize(serialized_data)
        self.assertEqual(original_data, deserialized_data)
    
    def test_complex_data(self):
        original_data = {'a': ['b', 'c', 1, Decimal('2.3')]}
        
        serialized_data = self.mixin.serialize(original_data)
        self.assertEqual(serialized_data, '{"a": ["b", "c", 1, 2.3]}')
        
        deserialized_data = self.mixin.deserialize(serialized_data)
        self.assertEqual(original_data, deserialized_data)
예제 #3
0
 def setUp(self):
     self.mixin = JSONClientMixin()
예제 #4
0
 def setUp(self):
     self.mixin = JSONClientMixin()