Skip to content

Commit 51fda72

Browse files
committed
Added test for setDecoder after Client creation
1 parent 29b2055 commit 51fda72

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/test_rejson.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,21 @@ def decode(self, obj):
209209
# Check the custom encoder
210210
self.assertTrue(rj.jsonset('cus', Path.rootPath(),
211211
CustomClass('foo', 'bar')))
212+
# Check the custom decoder
213+
obj = rj.jsonget('cus', Path.rootPath())
214+
self.assertIsNotNone(obj)
215+
self.assertEqual(CustomClass, obj.__class__)
216+
self.assertEqual('foo', obj.key)
217+
self.assertEqual('bar', obj.val)
218+
219+
# Test resetting the decoder after the client have been created
220+
rj.setDecoder(json.JSONDecoder())
221+
obj = rj.jsonget('cus', Path.rootPath())
222+
self.assertIsNotNone(obj)
223+
self.assertNotEqual(CustomClass, obj.__class__)
224+
225+
# Test setting the decoder after the client have been created
226+
rj.setDecoder(TestDecoder())
212227
obj = rj.jsonget('cus', Path.rootPath())
213228
self.assertIsNotNone(obj)
214229
self.assertEqual(CustomClass, obj.__class__)

0 commit comments

Comments
 (0)