def test_retrieve_value_from_response_invalid_key(self): keys = ["d.e.f", 'g.h'] resp_msg = { "a": { "b": { "3": 2, "43": 30, "c": [], "d": ['red', 'buggy', 'bumpers'], } } } try: ActionUtility.retrieve_value_from_response(keys, resp_msg) assert False except HttpActionFailure as e: assert str(e) == 'Unable to retrieve value for key from HTTP response: \'d\''
def test_retrieve_value_from_response(self): keys = ["a.b.3", 'a.b'] resp_msg = { "a": { "b": { "3": 2, "43": 30, "c": [], "d": ['red', 'buggy', 'bumpers'], } } } key_values = ActionUtility.retrieve_value_from_response(keys, resp_msg) assert key_values is not None assert key_values['${a.b.3}'] == 2 assert key_values['${a.b}'] is not None assert key_values['${a.b}']['3'] == 2 assert key_values['${a.b}']['d'][0] == 'red'