def test_api_decode_from_mongo(self): field = "$section1.group01.question1" encoded = _encode_for_mongo(field) self.assertEqual(encoded, ("%(dollar)ssection1%(dot)sgroup01%(dot)squestion1" % \ {"dollar": base64.b64encode("$"), \ "dot": base64.b64encode(".")})) decoded = _decode_from_mongo(encoded) self.assertEqual(field, decoded)
def decode_mongo_encoded_section_names(cls, data): return dict([(_decode_from_mongo(k), v) for k, v in data.iteritems()])