From edfb7b905081b844f818bc6f0ca0a09f814e9de8 Mon Sep 17 00:00:00 2001 From: Mark <mark@openappstack.net> Date: Mon, 9 Dec 2019 16:28:02 +0100 Subject: [PATCH] Change value from json functions --- test/login_logout/test/behave/features/steps/login.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/login_logout/test/behave/features/steps/login.py b/test/login_logout/test/behave/features/steps/login.py index ef1a5a5..4be7355 100644 --- a/test/login_logout/test/behave/features/steps/login.py +++ b/test/login_logout/test/behave/features/steps/login.py @@ -32,15 +32,13 @@ def step_impl(context, element, variable): @then(u'I expect that the "{variable}" in the json output is "{value}"') def step_impl(context, variable, value): - obj = get_object_from_json_body(context) - assert obj[variable] == context.oauth[value] + assert context.oauth[value] == get_value_from_json_body(context, variable) @then(u'I expect that the "{variable}" in the json output contains "{value}"') def step_impl(context, variable, value): - obj = get_object_from_json_body(context) - assert context.oauth[value] in obj[variable] + assert context.oauth[value] in get_value_from_json_body(context, variable) -def get_object_from_json_body(context): +def get_value_from_json_body(context, key): obj_serialized = context.behave_driver.get_element("body").text - return json.loads(obj_serialized) + return json.loads(obj_serialized)[key] -- GitLab