def test_json_unknown_version(self): m = pymacaroons.Macaroon(version=pymacaroons.MACAROON_V2) with self.assertRaises(ValueError) as exc: json.loads(json.dumps({ 'm': m.serialize(serializer=serializers.JsonSerializer()), 'v': bakery.LATEST_VERSION + 1 }), cls=bakery.MacaroonJSONDecoder) self.assertEqual('unknown bakery version 4', exc.exception.args[0])
def test_json_inconsistent_version(self): m = pymacaroons.Macaroon(version=pymacaroons.MACAROON_V1) with self.assertRaises(ValueError) as exc: json.loads(json.dumps({ 'm': json.loads(m.serialize( serializer=serializers.JsonSerializer())), 'v': bakery.LATEST_VERSION }), cls=bakery.MacaroonJSONDecoder) self.assertEqual('underlying macaroon has inconsistent version; ' 'got 1 want 2', exc.exception.args[0])