~ubuntuone-control-tower/ubuntu-sso-client/trunk

« back to all changes in this revision

Viewing changes to ubuntu_sso/qt/tests/test_sign_in_page.py

  • Committer: Tarmac
  • Author(s): Natalia B. Bidart
  • Date: 2012-02-24 18:13:24 UTC
  • mfrom: (884.1.15 use-login-only)
  • Revision ID: tarmac-20120224181324-ff3b9wofu64ueas8
- Move the 'choose sign in page' to client code (U1 control panel
  in this case) (LP: #933576).
- Make use of the 'login_only' parameter that is being passed to the
  UbuntuSSOWizard (LP: #939558).

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
 
"""The test suite for Sign In UI."""
18
 
 
19
 
from PyQt4 import QtGui
20
 
from twisted.internet import defer
21
 
 
22
 
from ubuntu_sso.qt import sign_in_page as gui
23
 
from ubuntu_sso.qt.ui.choose_sign_in_ui import Ui_ChooseSignInPage
24
 
from ubuntu_sso.qt.tests import BaseTestCase, FakeMainWindow, FakeSignal
25
 
 
26
 
 
27
 
class SignInPageTestCase(BaseTestCase):
28
 
    """Test the SignInPage code."""
29
 
 
30
 
    @defer.inlineCallbacks
31
 
    def setUp(self):
32
 
        """Initialize this test instance."""
33
 
        yield super(SignInPageTestCase, self).setUp()
34
 
        self.signals_results = []
35
 
        self.patch(gui.SignInPage, "existingAccountSelected", FakeSignal())
36
 
        self.patch(gui.SignInPage, "newAccountSelected", FakeSignal())
37
 
        self.patch(gui.SignInPage, "singInCanceled", FakeSignal())
38
 
        self.ui = gui.SignInPage(Ui_ChooseSignInPage(), QtGui.QPixmap())
39
 
 
40
 
    def test_show_event(self):
41
 
        """Check the page is initialized correctly."""
42
 
        wizard = FakeMainWindow()
43
 
        self.patch(self.ui, 'wizard', lambda *args: wizard)
44
 
        self.ui.initializePage()
45
 
        self.ui.show()
46
 
        self.addCleanup(self.ui.hide)
47
 
        self.assertTrue(self.ui.ui.existing_account_button.isDefault())
48
 
 
49
 
    # pylint: disable=W0212
50
 
    def test_set_next_existing(self):
51
 
        """Test _set_next_existing method."""
52
 
 
53
 
        def slot():
54
 
            """Fake slot."""
55
 
            self.signals_results.append(1)
56
 
        self.ui.existingAccountSelected.connect(slot)
57
 
        self.ui._set_next_existing()
58
 
        self.assertIn(1, self.signals_results)
59
 
 
60
 
    def test_set_next_new(self):
61
 
        """Test _set_next_existing method."""
62
 
 
63
 
        def slot():
64
 
            """Fake slot."""
65
 
            self.signals_results.append(1)
66
 
        self.ui.newAccountSelected.connect(slot)
67
 
        self.ui._set_next_new()
68
 
        self.assertIn(1, self.signals_results)
69
 
    # pylint: enable=W0212