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
1=== modified file 'setup.py'
2--- setup.py 2011-08-12 13:08:01 +0000
3+++ setup.py 2011-08-15 21:44:23 +0000
4@@ -114,7 +114,8 @@
5 path = os.getenv('PATH')
6 os.putenv('PATH', path + os.path.pathsep + os.path.join(
7 os.path.dirname(PyQt4.__file__), 'bin'))
8- if os.system('pyrcc4 -no-compress "%s" -o "%s"' % (qrc_file, py_file)) > 0:
9+ if os.system('pyrcc4 -no-compress "%s" -o "%s"' %
10+ (qrc_file, py_file)) > 0:
11 self.warn('Unable to generate python module {py_file}'
12 ' for resource file {qrc_file}'.format(
13 py_file=py_file, qrc_file=qrc_file))
14
15=== modified file 'ubuntuone_installer/gui/qt/gui.py'
16--- ubuntuone_installer/gui/qt/gui.py 2011-08-12 00:46:00 +0000
17+++ ubuntuone_installer/gui/qt/gui.py 2011-08-15 21:44:23 +0000
18@@ -87,7 +87,8 @@
19 SIGN_IN_SUBTITLE = _("Sign in with your existing Ubuntu One"
20 " username and password.")
21 TITLE_STYLE = "<span style=\"font-size:24px\">%s</span>"
22-
23+CREDENTIALS_ERROR_TITLE = _("Error getting credentials")
24+CREDENTIALS_ERROR = _('Application will close.\n\n%r')
25 # Invalid name logger
26 # pylint: disable=C0103
27 logger = setup_logging('qt.gui')
28@@ -149,7 +150,7 @@
29 def nextId(self):
30 """Return next page's ID."""
31 if self._next_id is None:
32- return super(LicensePage, self).nextId()
33+ return self.wizard().SIGNIN_PAGE
34 return self._next_id
35
36
37@@ -303,7 +304,6 @@
38
39 self.setSideWidget(SideWidget())
40 self.overlay = LoadingOverlay(self)
41- self.overlay.hide()
42
43 self.setOption(self.NoBackButtonOnStartPage, True)
44
45@@ -404,14 +404,23 @@
46 credtool = CredentialsManagementTool()
47 d = credtool.find_credentials()
48 d.addCallback(self.creds_cb)
49- d.addErrback(lambda exc: logger.error(
50- 'Error while getting the credentials: %r', exc))
51+ d.addErrback(self.creds_eb)
52
53 # Invalid name "closeEvent"
54 # pylint: disable=C0103
55
56+ def creds_eb(self, exc):
57+ """Handle credentials error."""
58+ self.LICENSE_PAGE._next_id = self.SIGNIN_PAGE
59+ self.critical(self, CREDENTIALS_ERROR_TITLE,
60+ CREDENTIALS_ERROR % exc.value)
61+ logger.error(
62+ 'Error while getting the credentials: %r', exc.value)
63+ self.close()
64+
65 def creds_cb(self, token):
66 """Change wizard flow if we have credentials."""
67+ self.overlay.hide()
68 if not token:
69 self.LICENSE_PAGE._next_id = self.SIGNIN_PAGE
70 else:
71
72=== modified file 'ubuntuone_installer/gui/qt/local_folders.py'
73--- ubuntuone_installer/gui/qt/local_folders.py 2011-08-11 17:46:11 +0000
74+++ ubuntuone_installer/gui/qt/local_folders.py 2011-08-15 21:44:23 +0000
75@@ -172,10 +172,11 @@
76 Returns a deferred that is triggered when the update is finished.
77
78 """
79+ # pylint: disable=W0702
80 try:
81 user_info = yield self.ui.add_folder_button.backend.account_info()
82 except:
83- logger.exception('Error while trying to update que quota:')
84+ logger.exception('Error while trying to get account info:')
85
86 quota = user_info['quota_total']
87 if cur_size > quota:
88@@ -206,11 +207,13 @@
89 def on_add_storage_button_clicked(self):
90 """user clicked on the "Add more storage" button."""
91
92+ # pylint: disable=W0702
93 try:
94 credtool = CredentialsManagementTool()
95 creds = yield credtool.find_credentials()
96 except:
97 logger.exception('Error while trying to update que quota:')
98+ creds = {}
99
100 if creds:
101 signed_url = sign_url(
102
103=== modified file 'ubuntuone_installer/gui/qt/tests/test_gui.py'
104--- ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-12 00:46:00 +0000
105+++ ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-15 21:44:23 +0000
106@@ -350,7 +350,6 @@
107 def test_start_control_panel_frozen(self):
108 """When frozen, the control-panel has a path."""
109 gui.AreYouSure.result = 0
110- help(self.patch)
111 # I can't patch sys because frozen is not there by default
112 gui.sys.frozen = True
113 self.patch(gui.subprocess, "Popen", self._set_called)
114@@ -558,7 +557,8 @@
115 class FakeCPBackend(object):
116 """Fake Control Panel backend."""
117
118- def account_info(*args):
119+ def account_info(self, *args):
120+ """Fake account info."""
121 return defer.succeed({"quota_total": 1000})
122
123
124@@ -906,3 +906,48 @@
125 self.assertEqual(
126 True,
127 self.ui.sideWidget().ui.states_frame.isVisible())
128+
129+
130+class FakeFailingCredentialsManagementTool(object):
131+
132+ """A fake CredentialsManagementTool that fails."""
133+
134+ def find_credentials(self):
135+ """Return a deferred that never triggers callback."""
136+ return defer.fail(Exception())
137+
138+
139+class CredsFailureMainWindowTestCase(BaseTestCase):
140+ """Test the qt main window."""
141+
142+ class_ui = gui.MainWindow
143+
144+ def setUp(self):
145+ """Initialize this test instance."""
146+ # Faking each SSO object instead of doing it lower
147+ # so we don't rely on any SSO behaviour
148+ self.patch(gui, "SetUpAccountController", FakeController)
149+ self.patch(gui, "TosController", FakeController)
150+ self.patch(gui, "EmailVerificationController", FakeController)
151+ self.patch(gui, "CurrentUserController", FakeController)
152+ self.patch(gui, "SuccessController", FakeController)
153+ self.patch(gui, "ForgottenPasswordController", FakeController)
154+ self.patch(gui, "ResetPasswordController", FakeController)
155+ self.patch(gui, "AreYouSure", FakeAreYouSure)
156+ self.patch(gui, "LoadingOverlay", FakeOverlay)
157+ self.patch(gui, "LocalFoldersPage", FakeLocalFoldersPage)
158+ self.patch(qt.preferences, "PreferencesPanel", FakePreferencesPanel)
159+ self.patch(qt.folders, "FoldersPanel", FakeFoldersPanel)
160+ self.patch(gui.QtGui.QMessageBox, "critical", self._set_called)
161+ self.patch(gui, "CredentialsManagementTool",
162+ FakeFailingCredentialsManagementTool)
163+ super(CredsFailureMainWindowTestCase, self).setUp()
164+
165+ def test_overlay_hiding(self):
166+ """Credential errors should make the overlay hide."""
167+ self.assertEqual(self.ui.overlay.hide_counter, 1)
168+
169+ def test_critical(self):
170+ """Credential errors should display a critical message."""
171+ self.assertEqual(self._called, ((self.ui, 'Error getting credentials',
172+ "Application will close.\n\nException()"), {}))

Subscribers

People subscribed via source and target branches