Merge lp:~ralsina/ubuntuone-windows-installer/start-with-overlay into lp:ubuntuone-windows-installer

Proposed by Roberto Alsina
Status: Merged
Approved by: Roberto Alsina
Approved revision: 36
Merged at revision: 31
Proposed branch: lp:~ralsina/ubuntuone-windows-installer/start-with-overlay
Merge into: lp:ubuntuone-windows-installer
Diff against target: 172 lines (+67/-9)
4 files modified
setup.py (+2/-1)
ubuntuone_installer/gui/qt/gui.py (+14/-5)
ubuntuone_installer/gui/qt/local_folders.py (+4/-1)
ubuntuone_installer/gui/qt/tests/test_gui.py (+47/-2)
To merge this branch: bzr merge lp:~ralsina/ubuntuone-windows-installer/start-with-overlay
Reviewer Review Type Date Requested Status
Diego Sarmentero (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+71422@code.launchpad.net

Commit message

* Change the default "Next Page" for the license page to not-None
* Block the UI (using the overlay) until the find_credentials call is done

Description of the change

* Change the default "Next Page" for the license page to not-None
* Block the UI (using the overlay) until the find_credentials call is done

To post a comment you must log in.
33. By Roberto Alsina

pep8 fix

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

As we discussed in IRC, some tests will be added for the fixes proposed in this branch.

review: Needs Fixing
34. By Roberto Alsina

added tests

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

> As we discussed in IRC, some tests will be added for the fixes proposed in
> this branch.

Tests added in revno 34

35. By Roberto Alsina

 no help

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Aproving but please fix a couple of lint issues:

== Python Lint Notices ==

ubuntuone_installer/gui/qt/gui.py:
    412: [C0111, MainWindow.creds_eb] Missing docstring

ubuntuone_installer/gui/qt/local_folders.py:
    178: [W0702, LocalFoldersPage.show_hide_offer] No exception type(s) specified
    213: [W0702, LocalFoldersPage.on_add_storage_button_clicked] No exception type(s) specified

ubuntuone_installer/gui/qt/tests/test_gui.py:
    561: [E0211, FakeCPBackend.account_info] Method has no argument
    561: [C0111, FakeCPBackend.account_info] Missing docstring

review: Approve
36. By Roberto Alsina

lint fixes

Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'setup.py'
--- setup.py 2011-08-12 13:08:01 +0000
+++ setup.py 2011-08-15 21:44:23 +0000
@@ -114,7 +114,8 @@
114 path = os.getenv('PATH')114 path = os.getenv('PATH')
115 os.putenv('PATH', path + os.path.pathsep + os.path.join(115 os.putenv('PATH', path + os.path.pathsep + os.path.join(
116 os.path.dirname(PyQt4.__file__), 'bin'))116 os.path.dirname(PyQt4.__file__), 'bin'))
117 if os.system('pyrcc4 -no-compress "%s" -o "%s"' % (qrc_file, py_file)) > 0:117 if os.system('pyrcc4 -no-compress "%s" -o "%s"' %
118 (qrc_file, py_file)) > 0:
118 self.warn('Unable to generate python module {py_file}'119 self.warn('Unable to generate python module {py_file}'
119 ' for resource file {qrc_file}'.format(120 ' for resource file {qrc_file}'.format(
120 py_file=py_file, qrc_file=qrc_file))121 py_file=py_file, qrc_file=qrc_file))
121122
=== modified file 'ubuntuone_installer/gui/qt/gui.py'
--- ubuntuone_installer/gui/qt/gui.py 2011-08-12 00:46:00 +0000
+++ ubuntuone_installer/gui/qt/gui.py 2011-08-15 21:44:23 +0000
@@ -87,7 +87,8 @@
87SIGN_IN_SUBTITLE = _("Sign in with your existing Ubuntu One"87SIGN_IN_SUBTITLE = _("Sign in with your existing Ubuntu One"
88 " username and password.")88 " username and password.")
89TITLE_STYLE = "<span style=\"font-size:24px\">%s</span>"89TITLE_STYLE = "<span style=\"font-size:24px\">%s</span>"
9090CREDENTIALS_ERROR_TITLE = _("Error getting credentials")
91CREDENTIALS_ERROR = _('Application will close.\n\n%r')
91# Invalid name logger92# Invalid name logger
92# pylint: disable=C010393# pylint: disable=C0103
93logger = setup_logging('qt.gui')94logger = setup_logging('qt.gui')
@@ -149,7 +150,7 @@
149 def nextId(self):150 def nextId(self):
150 """Return next page's ID."""151 """Return next page's ID."""
151 if self._next_id is None:152 if self._next_id is None:
152 return super(LicensePage, self).nextId()153 return self.wizard().SIGNIN_PAGE
153 return self._next_id154 return self._next_id
154155
155156
@@ -303,7 +304,6 @@
303304
304 self.setSideWidget(SideWidget())305 self.setSideWidget(SideWidget())
305 self.overlay = LoadingOverlay(self)306 self.overlay = LoadingOverlay(self)
306 self.overlay.hide()
307307
308 self.setOption(self.NoBackButtonOnStartPage, True)308 self.setOption(self.NoBackButtonOnStartPage, True)
309309
@@ -404,14 +404,23 @@
404 credtool = CredentialsManagementTool()404 credtool = CredentialsManagementTool()
405 d = credtool.find_credentials()405 d = credtool.find_credentials()
406 d.addCallback(self.creds_cb)406 d.addCallback(self.creds_cb)
407 d.addErrback(lambda exc: logger.error(407 d.addErrback(self.creds_eb)
408 'Error while getting the credentials: %r', exc))
409408
410 # Invalid name "closeEvent"409 # Invalid name "closeEvent"
411 # pylint: disable=C0103410 # pylint: disable=C0103
412411
412 def creds_eb(self, exc):
413 """Handle credentials error."""
414 self.LICENSE_PAGE._next_id = self.SIGNIN_PAGE
415 self.critical(self, CREDENTIALS_ERROR_TITLE,
416 CREDENTIALS_ERROR % exc.value)
417 logger.error(
418 'Error while getting the credentials: %r', exc.value)
419 self.close()
420
413 def creds_cb(self, token):421 def creds_cb(self, token):
414 """Change wizard flow if we have credentials."""422 """Change wizard flow if we have credentials."""
423 self.overlay.hide()
415 if not token:424 if not token:
416 self.LICENSE_PAGE._next_id = self.SIGNIN_PAGE425 self.LICENSE_PAGE._next_id = self.SIGNIN_PAGE
417 else:426 else:
418427
=== modified file 'ubuntuone_installer/gui/qt/local_folders.py'
--- ubuntuone_installer/gui/qt/local_folders.py 2011-08-11 17:46:11 +0000
+++ ubuntuone_installer/gui/qt/local_folders.py 2011-08-15 21:44:23 +0000
@@ -172,10 +172,11 @@
172 Returns a deferred that is triggered when the update is finished.172 Returns a deferred that is triggered when the update is finished.
173173
174 """174 """
175 # pylint: disable=W0702
175 try:176 try:
176 user_info = yield self.ui.add_folder_button.backend.account_info()177 user_info = yield self.ui.add_folder_button.backend.account_info()
177 except:178 except:
178 logger.exception('Error while trying to update que quota:')179 logger.exception('Error while trying to get account info:')
179180
180 quota = user_info['quota_total']181 quota = user_info['quota_total']
181 if cur_size > quota:182 if cur_size > quota:
@@ -206,11 +207,13 @@
206 def on_add_storage_button_clicked(self):207 def on_add_storage_button_clicked(self):
207 """user clicked on the "Add more storage" button."""208 """user clicked on the "Add more storage" button."""
208209
210 # pylint: disable=W0702
209 try:211 try:
210 credtool = CredentialsManagementTool()212 credtool = CredentialsManagementTool()
211 creds = yield credtool.find_credentials()213 creds = yield credtool.find_credentials()
212 except:214 except:
213 logger.exception('Error while trying to update que quota:')215 logger.exception('Error while trying to update que quota:')
216 creds = {}
214217
215 if creds:218 if creds:
216 signed_url = sign_url(219 signed_url = sign_url(
217220
=== modified file 'ubuntuone_installer/gui/qt/tests/test_gui.py'
--- ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-12 00:46:00 +0000
+++ ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-15 21:44:23 +0000
@@ -350,7 +350,6 @@
350 def test_start_control_panel_frozen(self):350 def test_start_control_panel_frozen(self):
351 """When frozen, the control-panel has a path."""351 """When frozen, the control-panel has a path."""
352 gui.AreYouSure.result = 0352 gui.AreYouSure.result = 0
353 help(self.patch)
354 # I can't patch sys because frozen is not there by default353 # I can't patch sys because frozen is not there by default
355 gui.sys.frozen = True354 gui.sys.frozen = True
356 self.patch(gui.subprocess, "Popen", self._set_called)355 self.patch(gui.subprocess, "Popen", self._set_called)
@@ -558,7 +557,8 @@
558class FakeCPBackend(object):557class FakeCPBackend(object):
559 """Fake Control Panel backend."""558 """Fake Control Panel backend."""
560559
561 def account_info(*args):560 def account_info(self, *args):
561 """Fake account info."""
562 return defer.succeed({"quota_total": 1000})562 return defer.succeed({"quota_total": 1000})
563563
564564
@@ -906,3 +906,48 @@
906 self.assertEqual(906 self.assertEqual(
907 True,907 True,
908 self.ui.sideWidget().ui.states_frame.isVisible())908 self.ui.sideWidget().ui.states_frame.isVisible())
909
910
911class FakeFailingCredentialsManagementTool(object):
912
913 """A fake CredentialsManagementTool that fails."""
914
915 def find_credentials(self):
916 """Return a deferred that never triggers callback."""
917 return defer.fail(Exception())
918
919
920class CredsFailureMainWindowTestCase(BaseTestCase):
921 """Test the qt main window."""
922
923 class_ui = gui.MainWindow
924
925 def setUp(self):
926 """Initialize this test instance."""
927 # Faking each SSO object instead of doing it lower
928 # so we don't rely on any SSO behaviour
929 self.patch(gui, "SetUpAccountController", FakeController)
930 self.patch(gui, "TosController", FakeController)
931 self.patch(gui, "EmailVerificationController", FakeController)
932 self.patch(gui, "CurrentUserController", FakeController)
933 self.patch(gui, "SuccessController", FakeController)
934 self.patch(gui, "ForgottenPasswordController", FakeController)
935 self.patch(gui, "ResetPasswordController", FakeController)
936 self.patch(gui, "AreYouSure", FakeAreYouSure)
937 self.patch(gui, "LoadingOverlay", FakeOverlay)
938 self.patch(gui, "LocalFoldersPage", FakeLocalFoldersPage)
939 self.patch(qt.preferences, "PreferencesPanel", FakePreferencesPanel)
940 self.patch(qt.folders, "FoldersPanel", FakeFoldersPanel)
941 self.patch(gui.QtGui.QMessageBox, "critical", self._set_called)
942 self.patch(gui, "CredentialsManagementTool",
943 FakeFailingCredentialsManagementTool)
944 super(CredsFailureMainWindowTestCase, self).setUp()
945
946 def test_overlay_hiding(self):
947 """Credential errors should make the overlay hide."""
948 self.assertEqual(self.ui.overlay.hide_counter, 1)
949
950 def test_critical(self):
951 """Credential errors should display a critical message."""
952 self.assertEqual(self._called, ((self.ui, 'Error getting credentials',
953 "Application will close.\n\nException()"), {}))

Subscribers

People subscribed via source and target branches