From dae14c1f701affd63df72da4d03d427b9dfdd865 Mon Sep 17 00:00:00 2001 From: Mark <mark@openappstack.net> Date: Thu, 2 Apr 2020 13:42:53 +0200 Subject: [PATCH] Make steps more expressive --- .../test/behave/features/login.feature | 8 ++++---- .../test/behave/features/steps/login.py | 17 +++++++++-------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/test/login_logout/test/behave/features/login.feature b/test/login_logout/test/behave/features/login.feature index 05af331..9aa5248 100644 --- a/test/login_logout/test/behave/features/login.feature +++ b/test/login_logout/test/behave/features/login.feature @@ -16,10 +16,10 @@ Scenario: Open the oAuth application and Login witha valid user Scenario: Get OpenID Connect userdata for testuser When I open the oauth client "userinfo" URL - Then I expect that the "preferred_username" in the json output is "username" - And I expect that the "email" in the json output is "email" - And I expect that the "openappstack_roles" in the json output contains "role" - And I expect that the "name" in the json output is "username" + Then I expect that the "preferred_username" in the json output is the same as oauth variable "username" + And I expect that the "email" in the json output is the same as oauth variable "email" + And I expect that the "openappstack_roles" in the json output contains the value of oauth variable "role" + And I expect that the "name" in the json output is the same as oauth variable "username" Scenario: Logout When I open the oauth client "logout" URL diff --git a/test/login_logout/test/behave/features/steps/login.py b/test/login_logout/test/behave/features/steps/login.py index 16da434..2cfe49d 100644 --- a/test/login_logout/test/behave/features/steps/login.py +++ b/test/login_logout/test/behave/features/steps/login.py @@ -30,20 +30,21 @@ def step_impl(context, element, variable): value = context.oauth[variable] assert value in elem.text +@then(u'I expect that the "{variable}" in the json output is the same as oauth variable "{value}"') +def step_impl(context, variable, value) + assert context.oauth[value] == get_value_from_json_body(context, variable) + @then(u'I expect that the "{variable}" in the json output is "{value}"') def step_impl(context, variable, value): - if value in context.oauth: - assert context.oauth[value] == get_value_from_json_body(context, variable) - else: - assert value == get_value_from_json_body(context, variable) + assert value == get_value_from_json_body(context, variable) +@then(u'I expect that the "{variable}" in the json output contains the value of oauth variable "{value}"') +def step_impl(context, variable, value): + assert context.oauth[value] in 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): - if value in context.oauth: - assert context.oauth[value] in get_value_from_json_body(context, variable) - else: - assert value in get_value_from_json_body(context, variable) + assert value in get_value_from_json_body(context, variable) def get_value_from_json_body(context, key): obj_serialized = context.behave_driver.get_element("body").text -- GitLab