~rmcbride/ubuntuone-testing/newmusicstore1

« back to all changes in this revision

Viewing changes to ubuntuone/web/tests/sst/shared/actions/teardown.py

  • Committer: Tarmac
  • Author(s): Leo Arias
  • Date: 2012-03-22 17:01:01 UTC
  • mfrom: (84.1.8 logout)
  • Revision ID: tarmac-20120322170101-ivk7tkeerfzw0f31
Added tear down actions for tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
 
3
# Copyright 2012 Canonical Ltd.
 
4
#
 
5
# This program is free software: you can redistribute it and/or modify it
 
6
# under the terms of the GNU General Public License version 3, as published
 
7
# by the Free Software Foundation.
 
8
#
 
9
# This program is distributed in the hope that it will be useful, but
 
10
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
12
# PURPOSE.  See the GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License along
 
15
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 
 
17
"""Tear down actions for Ubuntu One sst tests."""
 
18
 
 
19
from sst.actions import *
 
20
from sst.actions import browser
 
21
 
 
22
import actions.header as header_actions
 
23
import actions.sso as sso_actions
 
24
 
 
25
def tear_down():
 
26
    go_to()
 
27
    if header_actions.is_logged_in():
 
28
        _prevent_unsaved_data_confirmation()
 
29
        header_actions.logout()
 
30
        sso_actions.assert_logout()
 
31
 
 
32
def _prevent_unsaved_data_confirmation():
 
33
    """The browser might have unsaved data and ask for a confirmation before
 
34
    logging out. This will prevent that dialog to appear.
 
35
 
 
36
    """
 
37
    browser.execute_script("window.onbeforeunload = function(e){};")