From 43d9474d392d71b82e4f5a1cc574bd5eccbbcad4 Mon Sep 17 00:00:00 2001 From: Varac <varac@varac.net> Date: Wed, 12 Jun 2019 16:50:48 +0200 Subject: [PATCH] Changes from review of !107 --- test/behave/environment.py | 0 test/behave/features/environment.py | 43 ++++++++++++----------------- test/behave/features/steps/login.py | 4 +-- 3 files changed, 19 insertions(+), 28 deletions(-) delete mode 100644 test/behave/environment.py diff --git a/test/behave/environment.py b/test/behave/environment.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/behave/features/environment.py b/test/behave/features/environment.py index 9bc350cc9..dc46d648b 100644 --- a/test/behave/features/environment.py +++ b/test/behave/features/environment.py @@ -35,36 +35,27 @@ def before_all(context): def before_tag(context, tag): + def get_values(app): + values = {} + values['url'] = userdata.get(app + '.url') + values['username'] = \ + userdata.get(app + '.username', 'admin') + values['password'] = \ + userdata.get(app + '.password') + assert values['url'], '{0}.url variable missing in' \ + 'userdata. Provide it with "-D {0}.url".'.format(app) + assert values['username'], '{0}.username variable missing in' \ + 'userdata. Provide it with "-D {0}.username".'.format(app) + assert values['password'], '{0}.password variable missing in' \ + 'userdata. Provide it with "-D {0}.password".'.format(app) + return(values) + userdata = context.config.userdata if tag == 'grafana': - context.grafana = {} - context.grafana['url'] = userdata.get('grafana.url') - context.grafana['username'] = \ - userdata.get('grafana.username', 'admin') - context.grafana['password'] = \ - userdata.get('grafana.password') - - assert context.grafana['url'], 'grafana url variable missing in' \ - 'userdata. Provide it with "-D grafana.url".' - assert context.grafana['username'], 'grafana username variable' \ - 'missing in userdata. Provide it with "-D grafana.username".' - assert context.grafana['password'], 'grafana password variable' \ - 'missing in userdata. Provide it with "-D grafana.password".' + context.grafana = get_values('grafana') if tag == 'nextcloud': - context.nextcloud = {} - context.nextcloud['url'] = userdata.get('nextcloud.url') - context.nextcloud['username'] = \ - userdata.get('nextcloud.username', 'admin') - context.nextcloud['password'] = \ - userdata.get('nextcloud.password') - - assert context.nextcloud['url'], 'Nextcloud url variable missing in' \ - 'userdata. Provide it with "-D nextcloud.url".' - assert context.nextcloud['username'], 'Nextcloud username variable' \ - 'missing in userdata. Provide it with "-D nextcloud.username".' - assert context.nextcloud['password'], 'Nextcloud password variable' \ - 'missing in userdata. Provide it with "-D nextcloud.password".' + context.grafana = get_values('nextcloud') diff --git a/test/behave/features/steps/login.py b/test/behave/features/steps/login.py index 21bfe2386..b907459c5 100644 --- a/test/behave/features/steps/login.py +++ b/test/behave/features/steps/login.py @@ -6,14 +6,14 @@ from behave_webdriver.steps import * @when(u'I open the nextcloud URL') @given(u'I open the nextcloud URL') def step_impl(context): - """Login to nextcloud.""" + """Open nextcloud URL.""" context.behave_driver.get(context.nextcloud['url']) @when(u'I open the grafana URL') @given(u'I open the grafana URL') def step_impl(context): - """Login to grafana.""" + """Open grafana URL.""" context.behave_driver.get(context.grafana['url']) -- GitLab