def test_raises_decode_error_convert_json_string_to_dict(self): path = "/a/b[json]/c" dictionary = { "a": { "b": "{ 'c': 'hello' }", "c": "bye" } } param = Parameter(path) with self.assertRaises(JSONDecodeError) as context: param.extract_validated_value(dictionary) self.assertTrue("Expecting property name enclosed in double quotes" in context.exception.msg)
def test_can_get_value_from_dict_with_jwt_by_path(self): path = "/a/b[jwt]/sub" dictionary = { "a": { "b": TEST_JWT } } param = Parameter(path, 'event') response = param.extract_validated_value(dictionary) self.assertEqual("aadd1e0e-5807-4763-b1e8-5823bf631bb6", response)
def test_can_get_value_from_dict_with_json_by_path(self): path = "/a/b[json]/c" dictionary = { "a": { "b": '{ "c": "hello" }', "c": "bye" } } param = Parameter(path, 'event') response = param.extract_validated_value(dictionary) self.assertEqual("hello", response)
def test_can_get_dict_value_from_dict_by_path(self): path = "/a/b" dictionary = { "a": { "b": { "c": "hello" } } } param = Parameter(path) response = param.extract_validated_value(dictionary) self.assertEqual({"c": "hello"}, response)