~ubuntu-branches/ubuntu/precise/ubuntu-sso-client/precise

« back to all changes in this revision

Viewing changes to .pc/fix-938626.patch/ubuntu_sso/qt/tests/test_network_detection.py

  • Committer: Package Import Robot
  • Author(s): Natalia Bidart (nessita)
  • Date: 2012-02-22 16:53:51 UTC
  • mfrom: (1.1.32)
  • Revision ID: package-import@ubuntu.com-20120222165351-fvzfkcni6bq18goo
Tags: 2.99.5-0ubuntu1
* New upstream release:
  - Captcha loading is no longer failing for the Qt UI (LP: #933679).
  - Added stylesheets for the Qt UI.
  - Fixed: Qt UI: must call the backend passing reply_handler
    and error_handler (LP: #931452).
  - Make gettext return unicode strings. Also, transform arguments passed
    to the GLib spawnner to bytes (LP: #933632).
  - Try to load the qt main/ implementation when possible, if not default
    to the glib (LP: #933534).
  - Make the bin_dir discoverable when running from the system installation
    (LP: #933039).
  - Implement (so far dummy) timeout_func for the Qt frontend (LP: #933758).
* debian/control:
  - adding missing dependency on gnome-keyring for python-ubuntu-sso-client
    (LP: #938693).
* debian/patches/fix-938626.patch:
  - No more strings coming up from the Designer ui files so we ensure that
    those are marked for translation (LP: #938626).
* debian/watch: updated milestone to 2.99.5.

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 Network Detection UI."""
 
18
 
 
19
from twisted.internet import defer
 
20
 
 
21
from PyQt4 import QtGui
 
22
 
 
23
from ubuntu_sso.qt import network_detection_page
 
24
from ubuntu_sso.qt.tests import (
 
25
    BaseTestCase,
 
26
    FakeWizardButtonStyle,
 
27
)
 
28
 
 
29
 
 
30
class NetworkDetectionTestCase(BaseTestCase):
 
31
 
 
32
    """Test the CurrentUserController."""
 
33
 
 
34
    @defer.inlineCallbacks
 
35
    def setUp(self):
 
36
        """Initialize this test instance."""
 
37
        yield super(NetworkDetectionTestCase, self).setUp()
 
38
        self.wizard = FakeWizardButtonStyle()
 
39
        self.network_detection = network_detection_page.NetworkDetectionPage()
 
40
        self.patch(self.network_detection, 'wizard', self._get_wizard)
 
41
 
 
42
    def _get_wizard(self):
 
43
        """Fake wizard method for wizard page."""
 
44
        return self.wizard
 
45
 
 
46
    # pylint: disable=W0212
 
47
    def test_initialize_page(self):
 
48
        """Check Network detection initialize page."""
 
49
        self.network_detection.initializePage()
 
50
        self.assertEqual(self.wizard._next_id, None)
 
51
        self.assertTrue(('setButtonLayout', ([
 
52
            QtGui.QWizard.Stretch,
 
53
            QtGui.QWizard.CustomButton1,
 
54
            QtGui.QWizard.CancelButton], {})),
 
55
            self.wizard.called)
 
56
 
 
57
    def test_initialize_page_button_property(self):
 
58
        """Test the Try Again button properties."""
 
59
        self.patch(self.network_detection,
 
60
            "wizard", FakeWizardButtonStyle)
 
61
        self.network_detection.initializePage()
 
62
        self.assertTrue(self.network_detection.btn_try_again.isDefault())
 
63
        self.assertIn('polish', self.network_detection.btn_try_again.data)
 
64
        self.assertIn('unpolish', self.network_detection.btn_try_again.data)
 
65
        self.assertEqual(
 
66
            self.network_detection.btn_try_again.data['polish'],
 
67
            self.network_detection.btn_try_again)
 
68
        self.assertEqual(
 
69
            self.network_detection.btn_try_again.data['unpolish'],
 
70
            self.network_detection.btn_try_again)
 
71
 
 
72
    def test_try_again_with_connection(self):
 
73
        """Check try again method with connection."""
 
74
        self.patch(network_detection_page.networkstate, 'is_machine_connected',
 
75
            lambda: True)
 
76
        self.wizard._next_id = -1
 
77
        if 'next' in self.wizard.data:
 
78
            self.wizard.data.pop('next')
 
79
        self.network_detection.try_again()
 
80
        self.assertEqual(self.wizard._next_id, None)
 
81
        self.assertTrue(self.wizard.data.get('next', False))
 
82
 
 
83
    def test_try_again_without_connection(self):
 
84
        """Check try again method without connection."""
 
85
        self.patch(network_detection_page.networkstate, 'is_machine_connected',
 
86
            lambda: False)
 
87
        self.wizard._next_id = -1
 
88
        if 'next' in self.wizard.data:
 
89
            self.wizard.data.pop('next')
 
90
        self.network_detection.try_again()
 
91
        self.assertEqual(self.wizard._next_id, -1)
 
92
        self.assertFalse(self.wizard.data.get('next', False))
 
93
    # pylint: enable=W0212