From e6c10b18616edcbf9548af03c9d07a018100f07c Mon Sep 17 00:00:00 2001 From: Thais Siqueira Date: Mon, 17 Apr 2017 17:27:55 -0300 Subject: Logs user out after failed functional test https://github.com/pixelated/project-issues/issues/433 with @anikarni --- service/test/functional/features/environment.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'service/test/functional/features/environment.py') diff --git a/service/test/functional/features/environment.py b/service/test/functional/features/environment.py index bc2e1283..379583bc 100644 --- a/service/test/functional/features/environment.py +++ b/service/test/functional/features/environment.py @@ -30,6 +30,7 @@ from pixelated.resources.features_resource import FeaturesResource from test.support.integration import AppTestClient from steps.common import DEFAULT_IMPLICIT_WAIT_TIMEOUT_IN_S from steps import utils +from ..page_objects import BackupAccountPage class UnsuportedWebDriverError(Exception): @@ -135,12 +136,21 @@ def after_feature(context, feature): def after_step(context, step): - _debug_on_error(context, step) - _save_screenshot(context, step) + if step.status == 'failed': + _debug_on_error(context, step) + _save_screenshot(context, step) + _logout(context, step) + + +def _logout(context, step): + if context.browser.current_url == context.inbox_url: + utils.log_out() + elif context.browser.current_url == context.backup_account_url: + BackupAccountPage().logout() def _debug_on_error(context, step): - if step.status == 'failed' and context.config.userdata.getbool("debug"): + if context.config.userdata.getbool("debug"): try: import ipdb ipdb.post_mortem(step.exc_traceback) @@ -150,8 +160,7 @@ def _debug_on_error(context, step): def _save_screenshot(context, step): - if (step.status == 'failed' and - context.config.userdata.getbool("screenshots", True)): + if context.config.userdata.getbool("screenshots", True): timestamp = time.strftime("%Y-%m-%d-%H-%M-%S") filename = _slugify('{} failed {}'.format(timestamp, str(step.name))) filepath = os.path.join('screenshots', filename + '.png') -- cgit v1.2.3