summaryrefslogtreecommitdiff
path: root/service/test/functional/features/environment.py
diff options
context:
space:
mode:
authorThais Siqueira <thais.siqueira@gmail.com>2017-04-17 17:27:55 -0300
committerThais Siqueira <thais.siqueira@gmail.com>2017-04-17 17:27:55 -0300
commite6c10b18616edcbf9548af03c9d07a018100f07c (patch)
treed7c9df407548f300def5dc4d8793a3778d83ffa0 /service/test/functional/features/environment.py
parente7f9489d73551eba9434efe2e39ba5e75ab003d7 (diff)
Logs user out after failed functional test
https://github.com/pixelated/project-issues/issues/433 with @anikarni
Diffstat (limited to 'service/test/functional/features/environment.py')
-rw-r--r--service/test/functional/features/environment.py19
1 files changed, 14 insertions, 5 deletions
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')