def test_converts_persistent_mutables_to_default_types(self):
        # On the remote side the data is not stored, therfore we can
        # convert persistent mutables to default types in order to be
        # able to dump it to json.

        serializer = BrainSerializer()
        self.assertEquals(dict, type(serializer._encode(PersistentMapping())),
                          'PersistentMapping should be converted to dict')
        self.assertEquals(list, type(serializer._encode(PersistentList())),
                          'PersistentList should be converted to list')

        self.assertEquals(dict, type(serializer._encode({'dict': PersistentMapping()})['dict']),
                          'Dicts should be encoded recursively')
        self.assertEquals(list, type(serializer._encode([PersistentList()])[0]),
                          'Lists should be encoded recursively')
 def test_converts_dates(self):
     serializer = BrainSerializer()
     data = {'python_datetime': datetime(2014, 12, 22, 15, 30),
             'zope_DateTime': DateTime('2001/11/14 13:22')}
     self.assertEquals(
         data,
         serializer._decode_data(json.loads(
                 json.dumps(serializer._encode(data)))))