Merge lp:~nataliabidart/ubuntuone-windows-installer/stable-3-0-update-2.99.3 into lp:ubuntuone-windows-installer/stable-3-0

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 98
Merged at revision: 97
Proposed branch: lp:~nataliabidart/ubuntuone-windows-installer/stable-3-0-update-2.99.3
Merge into: lp:ubuntuone-windows-installer/stable-3-0
Diff against target: 582 lines (+355/-22)
6 files modified
scripts/setup.py (+10/-6)
ubuntuone_installer/gui/qt/gui.py (+47/-14)
ubuntuone_installer/gui/qt/network_detection.py (+76/-0)
ubuntuone_installer/gui/qt/tests/__init__.py (+19/-1)
ubuntuone_installer/gui/qt/tests/test_gui.py (+108/-1)
ubuntuone_installer/gui/qt/tests/test_network_detection.py (+95/-0)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-windows-installer/stable-3-0-update-2.99.3
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Review via email: mp+90963@code.launchpad.net

Commit message

[ Diego Sarmentero <email address hidden> ]
  - Added the missing page: No network detected (LP: #804610).
  - Update setup.py script to create the bundle.

To post a comment you must log in.
98. By Natalia Bidart

Attaching bug number.

Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/setup.py'
2--- scripts/setup.py 2012-01-09 14:36:13 +0000
3+++ scripts/setup.py 2012-02-01 19:46:19 +0000
4@@ -207,13 +207,14 @@
5
6 # Build UI files, copy packages.
7 dest_dir = os.path.join(
8- "..", "..", "installed", "Lib", "site-packages", "ubuntu_sso")
9+ "..", "..", "installed", "Lib", "site-packages")
10+ dest_sso = os.path.join(dest_dir, "ubuntu_sso")
11 start_dir = os.getcwd()
12 os.chdir(os.path.join("sources", "ubuntu-sso-client"))
13 os.system("python setup.py build")
14 os.system("python setup.py install --prefix=%s" %
15 os.path.join("..", "..", "installed"))
16- shutil.copytree("ubuntu_sso", dest_dir)
17+ shutil.copytree("ubuntu_sso", dest_sso)
18 sso_revno = subprocess.Popen(
19 ["bzr", "revno", "."],
20 stdout=subprocess.PIPE).communicate()[0]
21@@ -222,7 +223,8 @@
22 os.chdir(os.path.join("sources", "ubuntuone-client"))
23 shutil.copy(os.path.join("windows", "clientdefs.py"),
24 os.path.join("ubuntuone", "clientdefs.py"))
25- shutil.copytree("ubuntuone", dest_dir)
26+ dest_client = os.path.join(dest_dir, "ubuntuone")
27+ shutil.copytree("ubuntuone", dest_client)
28 u1client_revno = subprocess.Popen(
29 ["bzr", "revno", "."],
30 stdout=subprocess.PIPE).communicate()[0]
31@@ -231,8 +233,9 @@
32 os.chdir(os.path.join("sources", "ubuntuone-control-panel"))
33 os.system("python setup.py build")
34 # Copying by hand because the install is borked
35+ dest_cp = os.path.join(dest_dir, "ubuntuone", "controlpanel")
36 shutil.copytree(os.path.join("ubuntuone", "controlpanel"),
37- dest_dir)
38+ dest_cp)
39 u1cp_revno = subprocess.Popen(
40 ["bzr", "revno", "."],
41 stdout=subprocess.PIPE).communicate()[0]
42@@ -241,7 +244,8 @@
43 os.chdir(os.path.join("sources", "ubuntuone-windows-installer"))
44 os.system("python setup.py build")
45 # Copying by hand because the install is borked
46- shutil.copytree("ubuntuone_installer", dest_dir)
47+ dest_installer = os.path.join(dest_dir, "ubuntuone_installer")
48+ shutil.copytree("ubuntuone_installer", dest_installer)
49 u1inst_revno = subprocess.Popen(
50 ["bzr", "revno", "."],
51 stdout=subprocess.PIPE).communicate()[0]
52@@ -346,9 +350,9 @@
53 'configglue',
54 'configglue.app',
55 'configglue.inischema',
56- 'configglue.pyschema.glue',
57 'configglue.inischema.glue',
58 'configglue.inischema.parsers',
59+ 'comtypes',
60 ],
61 'excludes': ['fsm'],
62 "dll_excludes": [
63
64=== modified file 'ubuntuone_installer/gui/qt/gui.py'
65--- ubuntuone_installer/gui/qt/gui.py 2012-01-09 21:50:40 +0000
66+++ ubuntuone_installer/gui/qt/gui.py 2012-02-01 19:46:19 +0000
67@@ -18,8 +18,10 @@
68
69 import gettext
70
71+from twisted.internet import defer
72 from PyQt4 import QtGui, QtCore
73
74+from ubuntu_sso import networkstate
75 from ubuntu_sso.qt.gui import (
76 SSOWizardPage,
77 EmailVerificationPage,
78@@ -74,6 +76,7 @@
79 from ubuntuone_installer.gui.qt.folders import FoldersPage
80 from ubuntuone_installer.gui.qt.forgotten import ForgottenPasswordController
81 from ubuntuone_installer.gui.qt.local_folders import LocalFoldersPage
82+from ubuntuone_installer.gui.qt.network_detection import NetworkDetectionPage
83 from ubuntuone_installer.gui.qt.preferences import PreferencesPage
84 from ubuntuone_installer.gui.qt.sync_now_or_later import SyncNowOrLaterPage
85 from ubuntuone_installer.gui.qt.setup_account import SetupAccountPage
86@@ -151,7 +154,6 @@
87 """Wizard Page that displays the license info and links to the GPL."""
88
89 def __init__(self, parent=None):
90- self._next_id = None
91 super(LicensePage, self).__init__(license_ui.Ui_Form(), None, parent)
92 self.header.setVisible(False)
93 self.ui.textBrowser.setHtml(qt.LICENSE_CONTENT)
94@@ -163,7 +165,7 @@
95 def initializePage(self):
96 """Setup UI details."""
97 # Set the right texts and connections for buttons
98- self.setButtonText(QtGui.QWizard.NextButton, _("Agree && continue"))
99+ self.setButtonText(QtGui.QWizard.CustomButton1, _("Agree && continue"))
100 self.setButtonText(QtGui.QWizard.CancelButton,
101 _("Disagree && uninstall"))
102
103@@ -179,19 +181,30 @@
104 QtGui.QWizard.CancelButton,
105 QtGui.QWizard.BackButton,
106 QtGui.QWizard.Stretch,
107- QtGui.QWizard.NextButton,
108- QtGui.QWizard.FinishButton])
109+ QtGui.QWizard.CustomButton1])
110
111- self.agree_button = self.wizard().button(QtGui.QWizard.NextButton)
112+ self.agree_button = self.wizard().button(QtGui.QWizard.CustomButton1)
113 self.agree_button.setDefault(True)
114 self.agree_button.style().unpolish(self.agree_button)
115 self.agree_button.style().polish(self.agree_button)
116+ self.wizard().customButtonClicked.connect(self.check_connection)
117+
118+ # pylint: disable=W0212
119+ @defer.inlineCallbacks
120+ def check_connection(self, button_id):
121+ """Decide next ID based on network detection."""
122+ if button_id == QtGui.QWizard.CustomButton1:
123+ connected = yield self.wizard().check_connection()
124+ if connected:
125+ self.next = self.wizard().SIGN_IN_PAGE_ID
126+ else:
127+ self.next = self.wizard()._next_id
128+ self.wizard().next()
129+ # pylint: enable=W0212
130
131 def nextId(self):
132- """Return next page's ID."""
133- if self._next_id is None:
134- return self.wizard().SIGNIN_PAGE
135- return self._next_id
136+ """Return the next page ID."""
137+ return self.next
138
139
140 class SignInPage(SSOWizardPage):
141@@ -394,6 +407,7 @@
142 # pylint: disable=C0103
143 self.license_page = LicensePage()
144 self.LICENSE_PAGE = self.addPage(self.license_page)
145+ self.network_page = NetworkDetectionPage()
146
147 #SSO Pages
148 title_page = TITLE_STYLE % SIGN_IN
149@@ -450,7 +464,8 @@
150 self.reset_password.ui.reset_password_button.clicked.connect(
151 self.overlay.show)
152
153- self.SIGNIN_PAGE = self.addPage(self.sign_in_page)
154+ self.SIGN_IN_PAGE_ID = self.addPage(self.sign_in_page)
155+ self.NETWORK_DETECTION_PAGE_ID = self.addPage(self.network_page)
156 self.setup_account_page_id = self.addPage(self.setup_account)
157 self.email_verification_page_id = self.addPage(self.email_verification)
158 self.current_user_page_id = self.addPage(self.current_user)
159@@ -478,15 +493,23 @@
160 # Set Wizard buttons style
161 self.button(QtGui.QWizard.NextButton).setDefault(True)
162
163+ self.set_start_page(installing)
164+
165+ # Invalid name "closeEvent"
166+ # pylint: disable=C0103
167+
168+ @defer.inlineCallbacks
169+ def set_start_page(self, installing):
170+ """Set the Wizard start page based in some conditions."""
171+ connected = yield self.check_connection()
172 if installing:
173 self.setStartId(self.LICENSE_PAGE)
174- else:
175+ elif connected:
176 self.setStartId(self.SIGNIN_PAGE)
177+ else:
178+ self.setStartId(self._next_id)
179 self.restart()
180
181- # Invalid name "closeEvent"
182- # pylint: disable=C0103
183-
184 def critical(self, message, page=None):
185 """Show a message at the bottom of the page on form errors."""
186 self.overlay.hide()
187@@ -513,6 +536,16 @@
188 else:
189 return QtGui.QWizard.nextId(self)
190
191+ @defer.inlineCallbacks
192+ def check_connection(self):
193+ """Return is machine is connected, False set Network Page as next."""
194+ # pylint: disable=W0703
195+ connected = yield networkstate.is_machine_connected()
196+ if not connected:
197+ self._next_id = self.NETWORK_DETECTION_PAGE_ID
198+ defer.returnValue(connected)
199+ # pylint: enable=W0703
200+
201 def login_success_slot(self):
202 """Called on successful login."""
203 self._next_id = self.SUCCESS_PAGE
204
205=== added file 'ubuntuone_installer/gui/qt/network_detection.py'
206--- ubuntuone_installer/gui/qt/network_detection.py 1970-01-01 00:00:00 +0000
207+++ ubuntuone_installer/gui/qt/network_detection.py 2012-02-01 19:46:19 +0000
208@@ -0,0 +1,76 @@
209+# -*- coding: utf-8 *-*
210+#
211+# Copyright 2011 Canonical Ltd.
212+#
213+# This program is free software: you can redistribute it and/or modify it
214+# under the terms of the GNU General Public License version 3, as published
215+# by the Free Software Foundation.
216+#
217+# This program is distributed in the hope that it will be useful, but
218+# WITHOUT ANY WARRANTY; without even the implied warranties of
219+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
220+# PURPOSE. See the GNU General Public License for more details.
221+#
222+# You should have received a copy of the GNU General Public License along
223+# with this program. If not, see <http://www.gnu.org/licenses/>.
224+
225+"""Widget to show if we don't detect a network connection."""
226+
227+import gettext
228+
229+from twisted.internet import defer
230+from PyQt4 import QtGui
231+
232+from ubuntu_sso import networkstate
233+
234+from ubuntuone_installer.gui.qt.ui import network_detection_ui
235+
236+_ = gettext.gettext
237+
238+
239+class NetworkDetectionPage(QtGui.QWizardPage):
240+
241+ """Widget to show if we don't detect a network connection."""
242+
243+ def __init__(self, parent=None):
244+ super(NetworkDetectionPage, self).__init__(parent)
245+ self.setTitle(_("Installing Ubuntu One"))
246+ self.ui = network_detection_ui.Ui_Form()
247+ self.ui.setupUi(self)
248+ self.btn_try_again = None
249+
250+ # pylint: disable=C0103
251+ def initializePage(self):
252+ """Set UI details."""
253+ self.wizard()._next_id = None
254+
255+ self.setButtonText(QtGui.QWizard.CustomButton1, _("Try again"))
256+ self.setButtonText(QtGui.QWizard.CancelButton,
257+ _("Close window and set up later"))
258+ self.wizard().setButtonLayout([
259+ QtGui.QWizard.Stretch,
260+ QtGui.QWizard.CustomButton1,
261+ QtGui.QWizard.CancelButton,
262+ ])
263+
264+ try:
265+ self.wizard().customButtonClicked.disconnect()
266+ except TypeError:
267+ pass
268+
269+ self.btn_try_again = self.wizard().button(QtGui.QWizard.CustomButton1)
270+ self.btn_try_again.setDefault(True)
271+ self.btn_try_again.style().unpolish(self.btn_try_again)
272+ self.btn_try_again.style().polish(self.btn_try_again)
273+ self.wizard().customButtonClicked.connect(self.try_again)
274+ # pylint: enable=C0103
275+
276+ @defer.inlineCallbacks
277+ def try_again(self, button_id=QtGui.QWizard.CustomButton1):
278+ """Test the connection again."""
279+ if button_id == QtGui.QWizard.CustomButton1:
280+ d = yield networkstate.is_machine_connected()
281+ if d:
282+ self.wizard()._next_id = self.wizard().SIGN_IN_PAGE_ID
283+ self.wizard().next()
284+ self.wizard()._next_id = None
285
286=== modified file 'ubuntuone_installer/gui/qt/tests/__init__.py'
287--- ubuntuone_installer/gui/qt/tests/__init__.py 2012-01-03 15:00:57 +0000
288+++ ubuntuone_installer/gui/qt/tests/__init__.py 2012-02-01 19:46:19 +0000
289@@ -156,6 +156,7 @@
290 self.overlay = FakeOverlay()
291 self.called = []
292 self.buttons = {}
293+ self._next_id = -1
294
295 # Invalid name "setButtonLayout", "setOption"
296 # pylint: disable=C0103
297@@ -177,11 +178,16 @@
298
299 class FakeWizardButtonStyle(FakeWizard):
300
301+ """Fake Wizard with button style implementation."""
302+
303+ SIGN_IN_PAGE_ID = 1
304+
305+ # pylint: disable=C0103
306 def __init__(self):
307 super(FakeWizardButtonStyle, self).__init__()
308 self.data = {}
309+ self.customButtonClicked = self
310
311- # pylint: disable=C0103
312 def setDefault(self, value):
313 """Fake setDefault for button."""
314 self.data['default'] = value
315@@ -191,6 +197,14 @@
316 return self.data['default']
317 # pylint: enable=C0103
318
319+ def connect(self, func):
320+ """Fake customButtonClicked connect."""
321+ self.data['connect'] = func
322+
323+ def disconnect(self, func):
324+ """Fake customButtonClicked disconnect."""
325+ self.data['disconnect'] = func
326+
327 def button(self, button_id):
328 """Fake the functionality of button on QWizard class."""
329 return self
330@@ -207,6 +221,10 @@
331 """Fake unpolish."""
332 self.data['unpolish'] = button
333
334+ def next(self):
335+ """Fake next for wizard."""
336+ self.data['next'] = True
337+
338
339 class FakeWizardPage(object):
340
341
342=== modified file 'ubuntuone_installer/gui/qt/tests/test_gui.py'
343--- ubuntuone_installer/gui/qt/tests/test_gui.py 2012-01-03 15:00:57 +0000
344+++ ubuntuone_installer/gui/qt/tests/test_gui.py 2012-02-01 19:46:19 +0000
345@@ -129,10 +129,21 @@
346 self.patch(qt.folders, "FoldersPanel", FakeFoldersPanel)
347 self.patch(gui.qt.utils, "add_syncdaemon_to_autostart", NO_OP)
348 self.patch(gui.backend, "ControlBackend", FakeBackend)
349+ self.patch(gui.networkstate, "is_machine_connected",
350+ lambda: defer.succeed(True))
351 yield super(MainWindowTestCase, self).setUp()
352 setup_page = self.ui.page(self.ui.setup_account_page_id)
353 setup_page.initializePage()
354
355+ def test_check_network_id(self):
356+ """Check that the Network Detect page is not the first one."""
357+ win = gui.MainWindow()
358+ # Check that NETWORK_DETECTION_PAGE_ID is greater than 1,
359+ # this means that is not the first or second page, which should be
360+ # LICENSE and SIGN_IN.
361+ # (SIGN_IN will be the first running without --install)
362+ self.assertTrue(win.NETWORK_DETECTION_PAGE_ID > 1)
363+
364 # pylint: disable=E1101
365 def test_setup_account_controller_params(self):
366 """Test with SetupAccountController params."""
367@@ -141,6 +152,93 @@
368 self.assertEqual(val, win)
369 self.assertEqual(win.setup_controller.args[0], ())
370
371+ def test_network_detection_connection_enabled(self):
372+ """Test the flow of the pages without connection."""
373+ self.patch(gui.networkstate, "is_machine_connected",
374+ lambda: defer.succeed(True))
375+ license_page = self.ui.page(self.ui.LICENSE_PAGE)
376+ self.ui.setStartId(self.ui.LICENSE_PAGE)
377+ self.ui.restart()
378+ self.ui.show()
379+ self.addCleanup(self.ui.hide)
380+ license_page.check_connection(QtGui.QWizard.CustomButton1)
381+ page_id = license_page.next
382+ self.assertEqual(page_id, self.ui.SIGN_IN_PAGE_ID)
383+
384+ def test_network_detection_connection_disabled(self):
385+ """Test the flow of the pages with connection."""
386+ self.patch(gui.networkstate, "is_machine_connected",
387+ lambda: defer.succeed(False))
388+ license_page = self.ui.page(self.ui.LICENSE_PAGE)
389+ self.ui.setStartId(self.ui.LICENSE_PAGE)
390+ self.ui.restart()
391+ self.ui.show()
392+ self.addCleanup(self.ui.hide)
393+ license_page.check_connection(QtGui.QWizard.CustomButton1)
394+ page_id = license_page.next
395+ self.assertEqual(page_id, self.ui.NETWORK_DETECTION_PAGE_ID)
396+
397+ def test_license_page_check_connection_no_button(self):
398+ """Check the state of next when another button is pressed."""
399+ license_page = self.ui.page(self.ui.LICENSE_PAGE)
400+ self.ui.setStartId(self.ui.LICENSE_PAGE)
401+ self.ui.restart()
402+ self.ui.show()
403+ self.addCleanup(self.ui.hide)
404+ license_page.next = -1
405+ license_page.check_connection(QtGui.QWizard.NextButton)
406+ page_id = license_page.next
407+ self.assertEqual(page_id, -1)
408+
409+ def test_network_detection_retry_fail(self):
410+ """Test the flow of the pages when the retry button is pressed."""
411+ self.patch(gui.networkstate, "is_machine_connected",
412+ lambda: defer.succeed(False))
413+ network_page = self.ui.page(self.ui.NETWORK_DETECTION_PAGE_ID)
414+ self.ui.setStartId(self.ui.NETWORK_DETECTION_PAGE_ID)
415+ self.ui.restart()
416+ self.ui.show()
417+ self.addCleanup(self.ui.hide)
418+ network_page.try_again()
419+ self.assertEqual(self.ui.currentId(),
420+ self.ui.NETWORK_DETECTION_PAGE_ID)
421+
422+ # pylint: disable=W0212
423+ @defer.inlineCallbacks
424+ def test_check_connection_with_connection(self):
425+ """Test the check_connection function with connection = True."""
426+ self.patch(gui.networkstate, "is_machine_connected",
427+ lambda: defer.succeed(True))
428+ self.ui._next_id = -1
429+ connected = yield self.ui.check_connection()
430+ self.assertNotEqual(self.ui._next_id,
431+ self.ui.NETWORK_DETECTION_PAGE_ID)
432+ self.assertTrue(connected)
433+
434+ @defer.inlineCallbacks
435+ def test_check_connection_with_no_connection(self):
436+ """Test the check_connection function with connection = False."""
437+ self.patch(gui.networkstate, "is_machine_connected",
438+ lambda: defer.succeed(False))
439+ connected = yield self.ui.check_connection()
440+ self.assertEqual(self.ui._next_id, self.ui.NETWORK_DETECTION_PAGE_ID)
441+ self.assertFalse(connected)
442+ self.assertFalse(False)
443+ # pylint: enable=W0212
444+
445+ def test_network_detection_retry_works(self):
446+ """Test the flow of the pages when the retry button is pressed."""
447+ self.patch(gui.networkstate, "is_machine_connected",
448+ lambda: defer.succeed(True))
449+ network_page = self.ui.page(self.ui.NETWORK_DETECTION_PAGE_ID)
450+ self.ui.setStartId(self.ui.NETWORK_DETECTION_PAGE_ID)
451+ self.ui.restart()
452+ self.ui.show()
453+ self.addCleanup(self.ui.hide)
454+ network_page.try_again()
455+ self.assertNotEqual(self.ui.currentId(),
456+ self.ui.NETWORK_DETECTION_PAGE_ID)
457+
458 def test_current_user_controller_params(self):
459 """Test with CurrentUserController params."""
460 win = gui.MainWindow()
461@@ -183,11 +281,20 @@
462 unicode(self.ui.sign_in_page.ui.message_label.text()),
463 u"")
464
465- def test_without_flag(self):
466+ def test_without_flag_connected(self):
467 """test with flag activated."""
468+ self.patch(gui.networkstate, "is_machine_connected",
469+ lambda: defer.succeed(True))
470 win = gui.MainWindow()
471 self.assertEqual(win.startId(), win.SIGNIN_PAGE)
472
473+ def test_without_flag_disconnected(self):
474+ """test with flag activated."""
475+ self.patch(gui.networkstate, "is_machine_connected",
476+ lambda: defer.succeed(False))
477+ win = gui.MainWindow()
478+ self.assertEqual(win.startId(), win.NETWORK_DETECTION_PAGE_ID)
479+
480 def test_initialize_page(self):
481 """Check the initializePage to ensure proper widgets visibility."""
482 setup_page = self.ui.page(self.ui.setup_account_page_id)
483
484=== added file 'ubuntuone_installer/gui/qt/tests/test_network_detection.py'
485--- ubuntuone_installer/gui/qt/tests/test_network_detection.py 1970-01-01 00:00:00 +0000
486+++ ubuntuone_installer/gui/qt/tests/test_network_detection.py 2012-02-01 19:46:19 +0000
487@@ -0,0 +1,95 @@
488+# -*- coding: utf-8 -*-
489+
490+# Copyright 2012 Canonical Ltd.
491+#
492+# This program is free software: you can redistribute it and/or modify it
493+# under the terms of the GNU General Public License version 3, as published
494+# by the Free Software Foundation.
495+#
496+# This program is distributed in the hope that it will be useful, but
497+# WITHOUT ANY WARRANTY; without even the implied warranties of
498+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
499+# PURPOSE. See the GNU General Public License for more details.
500+#
501+# You should have received a copy of the GNU General Public License along
502+# with this program. If not, see <http://www.gnu.org/licenses/>.
503+
504+"""The test suite for Network Detection UI."""
505+
506+from twisted.internet import defer
507+
508+from PyQt4 import QtGui
509+
510+from ubuntuone_installer.gui.qt import network_detection
511+from ubuntuone_installer.gui.qt.tests import (
512+ BaseTestCase,
513+ FakeWizardButtonStyle,
514+)
515+
516+
517+class NetworkDetectionTestCase(BaseTestCase):
518+
519+ """Test the CurrentUserController."""
520+
521+ @defer.inlineCallbacks
522+ def setUp(self):
523+ """Initialize this test instance."""
524+ yield super(NetworkDetectionTestCase, self).setUp()
525+ self.wizard = FakeWizardButtonStyle()
526+ self.network_detection_page = network_detection.NetworkDetectionPage()
527+ self.patch(self.network_detection_page, 'wizard', self._get_wizard)
528+
529+ def _get_wizard(self):
530+ """Fake wizard method for wizard page."""
531+ return self.wizard
532+
533+ # pylint: disable=W0212
534+ def test_initialize_page(self):
535+ """Check Network detection initialize page."""
536+ self.network_detection_page.initializePage()
537+ self.assertEqual(self.wizard._next_id, None)
538+ self.assertTrue(('setButtonLayout', ([
539+ QtGui.QWizard.Stretch,
540+ QtGui.QWizard.CustomButton1,
541+ QtGui.QWizard.CancelButton], {})),
542+ self.wizard.called)
543+
544+ def test_initialize_page_button_property(self):
545+ """Test the Try Again button properties."""
546+ self.patch(self.network_detection_page,
547+ "wizard", FakeWizardButtonStyle)
548+ self.network_detection_page.initializePage()
549+ self.assertTrue(self.network_detection_page.btn_try_again.isDefault())
550+ self.assertTrue(
551+ 'polish' in self.network_detection_page.btn_try_again.data)
552+ self.assertTrue(
553+ 'unpolish' in self.network_detection_page.btn_try_again.data)
554+ self.assertEqual(
555+ self.network_detection_page.btn_try_again.data['polish'],
556+ self.network_detection_page.btn_try_again)
557+ self.assertEqual(
558+ self.network_detection_page.btn_try_again.data['unpolish'],
559+ self.network_detection_page.btn_try_again)
560+
561+ def test_try_again_with_connection(self):
562+ """Check try again method with connection."""
563+ self.patch(network_detection.networkstate, 'is_machine_connected',
564+ lambda: True)
565+ self.wizard._next_id = -1
566+ if 'next' in self.wizard.data:
567+ self.wizard.data.pop('next')
568+ self.network_detection_page.try_again()
569+ self.assertEqual(self.wizard._next_id, None)
570+ self.assertTrue(self.wizard.data.get('next', False))
571+
572+ def test_try_again_without_connection(self):
573+ """Check try again method without connection."""
574+ self.patch(network_detection.networkstate, 'is_machine_connected',
575+ lambda: False)
576+ self.wizard._next_id = -1
577+ if 'next' in self.wizard.data:
578+ self.wizard.data.pop('next')
579+ self.network_detection_page.try_again()
580+ self.assertEqual(self.wizard._next_id, -1)
581+ self.assertFalse(self.wizard.data.get('next', False))
582+ # pylint: enable=W0212

Subscribers

People subscribed via source and target branches