Merge lp:~ralsina/ubuntu-sso-client/fix_merge_27 into lp:ubuntu-sso-client
- fix_merge_27
- Merge into trunk
Proposed by
Roberto Alsina
Status: | Merged |
---|---|
Merged at revision: | 705 |
Proposed branch: | lp:~ralsina/ubuntu-sso-client/fix_merge_27 |
Merge into: | lp:ubuntu-sso-client |
Diff against target: |
376 lines (+182/-13) 6 files modified
.bzrignore (+1/-0) data/qt/success_message.ui (+31/-0) ubuntu_sso/qt/controllers.py (+41/-7) ubuntu_sso/qt/gui.py (+41/-3) ubuntu_sso/qt/tests/test_qt_views.py (+28/-0) ubuntu_sso/qt/tests/test_windows.py (+40/-3) |
To merge this branch: | bzr merge lp:~ralsina/ubuntu-sso-client/fix_merge_27 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu One hackers | Pending | ||
Review via email: mp+57633@code.launchpad.net |
Commit message
Description of the change
Fix merge conflicts to trunk.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2011-03-14 12:22:58 +0000 |
3 | +++ .bzrignore 2011-04-14 08:48:33 +0000 |
4 | @@ -10,3 +10,4 @@ |
5 | ubuntu_sso/qt/email_verification_ui.py |
6 | ubuntu_sso/qt/setup_account_ui.py |
7 | ubuntu_sso/qt/terms_and_conditions_ui.py |
8 | +ubuntu_sso/qt/success_message_ui.py |
9 | |
10 | === added file 'data/qt/success_message.ui' |
11 | --- data/qt/success_message.ui 1970-01-01 00:00:00 +0000 |
12 | +++ data/qt/success_message.ui 2011-04-14 08:48:33 +0000 |
13 | @@ -0,0 +1,31 @@ |
14 | +<?xml version="1.0" encoding="UTF-8"?> |
15 | +<ui version="4.0"> |
16 | + <class>SuccessPage</class> |
17 | + <widget class="QWizardPage" name="SuccessPage"> |
18 | + <property name="geometry"> |
19 | + <rect> |
20 | + <x>0</x> |
21 | + <y>0</y> |
22 | + <width>400</width> |
23 | + <height>300</height> |
24 | + </rect> |
25 | + </property> |
26 | + <property name="windowTitle"> |
27 | + <string>WizardPage</string> |
28 | + </property> |
29 | + <layout class="QVBoxLayout" name="verticalLayout"> |
30 | + <item> |
31 | + <widget class="QLabel" name="success_message_label"> |
32 | + <property name="text"> |
33 | + <string>TextLabel</string> |
34 | + </property> |
35 | + <property name="alignment"> |
36 | + <set>Qt::AlignCenter</set> |
37 | + </property> |
38 | + </widget> |
39 | + </item> |
40 | + </layout> |
41 | + </widget> |
42 | + <resources/> |
43 | + <connections/> |
44 | +</ui> |
45 | |
46 | === modified file 'ubuntu_sso/qt/controllers.py' |
47 | --- ubuntu_sso/qt/controllers.py 2011-04-13 10:11:31 +0000 |
48 | +++ ubuntu_sso/qt/controllers.py 2011-04-14 08:48:33 +0000 |
49 | @@ -45,6 +45,7 @@ |
50 | SET_UP_ACCOUNT_BUTTON, |
51 | SIGN_IN_BUTTON, |
52 | SURNAME_ENTRY, |
53 | + SUCCESS, |
54 | TC_BUTTON, |
55 | VERIFY_EMAIL_TITLE, |
56 | VERIFY_EMAIL_CONTENT, |
57 | @@ -54,8 +55,6 @@ |
58 | |
59 | |
60 | logger = setup_logging('ubuntu_sso.controllers') |
61 | -# pylint: disable=W0511 |
62 | -# disabled warnings about TODO comments |
63 | |
64 | # pylint: disable=W0511 |
65 | # disabled warnings about TODO comments |
66 | @@ -182,10 +181,12 @@ |
67 | logger.error('Got error when login %s, error: %s', app_name, error) |
68 | self.message_box.critical(view, app_name, str(error)) |
69 | |
70 | + @inlineCallbacks |
71 | def on_logged_in(self, view, app_name, result): |
72 | """We managed to log in.""" |
73 | logger.info('Logged in for %s', app_name) |
74 | view.wizard().loginSuccess.emit(app_name, view.email) |
75 | + logger.debug('Wizard.loginSuccess emitted.') |
76 | |
77 | # use an ugly name just so have a simlar api as found in PyQt |
78 | #pylint: disable=C0103 |
79 | @@ -313,6 +314,7 @@ |
80 | # error are returned as a dict with the data we want to show. |
81 | self.message_box.critical(view, error['errtype'], error['email']) |
82 | |
83 | + @inlineCallbacks |
84 | def on_user_registered(self, view, app_name, result): |
85 | """Execute when the user did register.""" |
86 | logger.debug('SetUpAccountController.on_user_registered') |
87 | @@ -440,6 +442,20 @@ |
88 | view.wizard().next() |
89 | |
90 | |
91 | +class SuccessController(object): |
92 | + """Controller used for the success page.""" |
93 | + |
94 | + def __init__(self): |
95 | + """Create a new instance.""" |
96 | + |
97 | + #pylint: disable=C0103 |
98 | + def setupUi(self, view): |
99 | + """Setup the view.""" |
100 | + view.next = -1 |
101 | + view.success_message_label.setText(SUCCESS) |
102 | + #pylint: enable=C0103 |
103 | + |
104 | + |
105 | class UbuntuSSOWizardController(object): |
106 | """Controller used for the overall wizard.""" |
107 | |
108 | @@ -458,18 +474,20 @@ |
109 | self.user_cancellation_callback(self.app_name) |
110 | view.close() |
111 | |
112 | - def on_login_success(self, app_name, email): |
113 | + @inlineCallbacks |
114 | + def on_login_success(self, app_name, email, view): |
115 | """Process the success of a login.""" |
116 | logger.debug('UbuntuSSOWizardController.on_login_success') |
117 | result = yield self.login_success_callback(app_name, email) |
118 | - # TODO: what to do? |
119 | logger.debug('Result from callback is %s', result) |
120 | if result == 0: |
121 | logger.info('Success in calling the given success_callback') |
122 | + self.show_success_message(view) |
123 | else: |
124 | logger.info('Error in calling the given success_callback') |
125 | |
126 | - def on_registration_success(self, app_name, email): |
127 | + @inlineCallbacks |
128 | + def on_registration_success(self, app_name, email, view): |
129 | """Process the success of a registration.""" |
130 | logger.debug('UbuntuSSOWizardController.on_registration_success') |
131 | result = yield self.registration_success_callback(app_name, email) |
132 | @@ -477,14 +495,30 @@ |
133 | logger.debug('Result from callback is %s', result) |
134 | if result == 0: |
135 | logger.info('Success in calling the given registration_callback') |
136 | + self.show_success_message(view) |
137 | else: |
138 | logger.info('Success in calling the given registration_callback') |
139 | |
140 | + def show_success_message(self, view): |
141 | + """Show the success message in the view.""" |
142 | + logger.info('Showing success message.') |
143 | + # get the id of the success page, set it as the next id of the |
144 | + # current page and let the wizard move to the next step |
145 | + view.currentPage().next = view.success_page_id |
146 | + view.next() |
147 | + # show the finish button but with a close message |
148 | + buttons_layout = [] |
149 | + buttons_layout.append(QWizard.Stretch) |
150 | + buttons_layout.append(QWizard.FinishButton) |
151 | + view.setButtonLayout(buttons_layout) |
152 | + |
153 | #pylint: disable=C0103 |
154 | def setupUi(self, view): |
155 | """Setup the view.""" |
156 | view.button(QWizard.CancelButton).clicked.connect( |
157 | lambda: self.on_user_cancelation(view)) |
158 | - view.loginSuccess.connect(self.on_login_success) |
159 | - view.registrationSuccess.connect(self.on_registration_success) |
160 | + view.loginSuccess.connect( |
161 | + lambda app, email: self.on_login_success(app, email, view)) |
162 | + view.registrationSuccess.connect( |
163 | + lambda app, email: self.on_registration_success(app, email, view)) |
164 | #pylint: enable=C0103 |
165 | |
166 | === modified file 'ubuntu_sso/qt/gui.py' |
167 | --- ubuntu_sso/qt/gui.py 2011-04-13 10:11:31 +0000 |
168 | +++ ubuntu_sso/qt/gui.py 2011-04-14 08:48:33 +0000 |
169 | @@ -36,12 +36,14 @@ |
170 | from ubuntu_sso.qt.email_verification_ui import Ui_EmailVerificationPage |
171 | from ubuntu_sso.qt.setup_account_ui import Ui_SetUpAccountPage |
172 | from ubuntu_sso.qt.terms_and_conditions_ui import Ui_TosPage |
173 | +from ubuntu_sso.qt.success_message_ui import Ui_SuccessPage |
174 | # pylint: enable=F0401,E0611 |
175 | from ubuntu_sso.qt.controllers import ( |
176 | ChooseSignInController, |
177 | CurrentUserController, |
178 | EmailVerificationController, |
179 | SetUpAccountController, |
180 | + SuccessController, |
181 | TosController, |
182 | UbuntuSSOWizardController) |
183 | |
184 | @@ -394,6 +396,30 @@ |
185 | return self.ui.set_up_button |
186 | |
187 | |
188 | +class SuccessPage(QWizardPage): |
189 | + """Page used to display success message.""" |
190 | + |
191 | + def __init__(self, ui, controller, parent=None): |
192 | + """Create a new instance.""" |
193 | + QWizardPage.__init__(self, parent) |
194 | + self.ui = ui |
195 | + self.ui.setupUi(self) |
196 | + self.controller = controller |
197 | + self.controller.setupUi(self) |
198 | + self.next = -1 |
199 | + |
200 | + # pylint: disable=C0103 |
201 | + def nextId(self): |
202 | + """Return the next page id.""" |
203 | + return self.next |
204 | + # pylint: enable=C0103 |
205 | + |
206 | + @property |
207 | + def success_message_label(self): |
208 | + """Return the label used to show the message.""" |
209 | + return self.ui.success_message_label |
210 | + |
211 | + |
212 | class UbuntuSSOWizard(QWizard): |
213 | """Wizard used to create or use sso.""" |
214 | |
215 | @@ -428,9 +454,15 @@ |
216 | self.current_user = CurrentUserSignInPage(Ui_CurrentUserSignInPage(), |
217 | self.current_user_controller, |
218 | parent=self) |
219 | + self.success_controller = SuccessController() |
220 | + self.success = SuccessPage(Ui_SuccessPage(), self.success_controller, |
221 | + parent=self) |
222 | + # store the dis of the pages so that it is easier to access them later |
223 | + self._pages = {} |
224 | for page in [self.sign_in_page, self.setup_account, self.tos, |
225 | - self.email_verification, self.current_user]: |
226 | - self.addPage(page) |
227 | + self.email_verification, self.current_user, self.success]: |
228 | + self._pages[page] = self.addPage(page) |
229 | + |
230 | # set the buttons layout to only have cancel and back since the next |
231 | # buttons are the ones used in the diff pages. |
232 | buttons_layout = [] |
233 | @@ -439,7 +471,13 @@ |
234 | buttons_layout.append(QWizard.CancelButton) |
235 | self.setButtonLayout(buttons_layout) |
236 | self.setWindowTitle(app_name) |
237 | - controller.setupUi(self) |
238 | + self.controller = controller |
239 | + self.controller.setupUi(self) |
240 | + |
241 | + @property |
242 | + def success_page_id(self): |
243 | + """Return the id of the success page.""" |
244 | + return self._pages[self.success] |
245 | |
246 | |
247 | class UbuntuSSOClientGUI(object): |
248 | |
249 | === modified file 'ubuntu_sso/qt/tests/test_qt_views.py' |
250 | --- ubuntu_sso/qt/tests/test_qt_views.py 2011-03-30 10:57:29 +0000 |
251 | +++ ubuntu_sso/qt/tests/test_qt_views.py 2011-04-14 08:48:33 +0000 |
252 | @@ -25,6 +25,7 @@ |
253 | CurrentUserSignInPage, |
254 | EmailVerificationPage, |
255 | SetupAccountPage, |
256 | + SuccessPage, |
257 | TosPage) |
258 | # in linux we will be having a pylint warning because the code is not |
259 | # compiled since we are just targeting windows with it, later |
260 | @@ -35,6 +36,7 @@ |
261 | from ubuntu_sso.qt.email_verification_ui import Ui_EmailVerificationPage |
262 | from ubuntu_sso.qt.terms_and_conditions_ui import Ui_TosPage |
263 | from ubuntu_sso.qt.setup_account_ui import Ui_SetUpAccountPage |
264 | +from ubuntu_sso.qt.success_message_ui import Ui_SuccessPage |
265 | # pylint: enable=F0401 |
266 | |
267 | |
268 | @@ -333,3 +335,29 @@ |
269 | def test_set_up_button(self): |
270 | """Test the property that returns the set up button.""" |
271 | self.assertEqual(self.ui.set_up_button, self.widget.set_up_button) |
272 | + |
273 | + |
274 | +class SuccessPageTestCase(TestCase): |
275 | + """Test that the correct widgets are used.""" |
276 | + |
277 | + def setUp(self): |
278 | + """Setup tests.""" |
279 | + super(SuccessPageTestCase, self).setUp() |
280 | + self.ui = Ui_SuccessPage() |
281 | + self.controller = FakeController() |
282 | + self.widget = SuccessPage(self.ui, self.controller) |
283 | + |
284 | + def test_constructor(self): |
285 | + """Test that the constructor works as expected.""" |
286 | + mocker = Mocker() |
287 | + ui = mocker.mock() |
288 | + controller = mocker.mock() |
289 | + ui.setupUi(MATCH(lambda x: isinstance(x, SuccessPage))) |
290 | + controller.setupUi(MATCH(lambda x: isinstance(x, SuccessPage))) |
291 | + mocker.replay() |
292 | + self.widget = SuccessPage(self.ui, self.controller) |
293 | + |
294 | + def test_success_message_label(self): |
295 | + """Test that the correct label is returned.""" |
296 | + self.assertEqual(self.ui.success_message_label, |
297 | + self.widget.success_message_label) |
298 | |
299 | === modified file 'ubuntu_sso/qt/tests/test_windows.py' |
300 | --- ubuntu_sso/qt/tests/test_windows.py 2011-04-13 10:11:31 +0000 |
301 | +++ ubuntu_sso/qt/tests/test_windows.py 2011-04-14 08:48:33 +0000 |
302 | @@ -24,6 +24,7 @@ |
303 | CurrentUserController, |
304 | EmailVerificationController, |
305 | SetUpAccountController, |
306 | + SuccessController, |
307 | TosController, |
308 | UbuntuSSOWizardController) |
309 | from ubuntu_sso.utils.ui import ( |
310 | @@ -44,6 +45,7 @@ |
311 | SET_UP_ACCOUNT_BUTTON, |
312 | SIGN_IN_BUTTON, |
313 | SURNAME_ENTRY, |
314 | + SUCCESS, |
315 | TC_BUTTON, |
316 | VERIFY_EMAIL_TITLE, |
317 | VERIFY_EMAIL_CONTENT, |
318 | @@ -419,6 +421,25 @@ |
319 | self.controller.next_page(self.view) |
320 | |
321 | |
322 | +class SuccessControllerTestCase(MockerTestCase): |
323 | + """Test the success page controller.""" |
324 | + |
325 | + def setUp(self): |
326 | + """Set the tests.""" |
327 | + super(SuccessControllerTestCase, self).setUp() |
328 | + self.controller = SuccessController() |
329 | + self.view = self.mocker.mock() |
330 | + |
331 | + def test_set_ui(self): |
332 | + """Test the process that sets the ui.""" |
333 | + self.view.next = -1 |
334 | + self.view.success_message_label |
335 | + self.mocker.result(self.view) |
336 | + self.view.setText(SUCCESS) |
337 | + self.mocker.replay() |
338 | + self.controller.setupUi(self.view) |
339 | + |
340 | + |
341 | class UbuntuSSOWizardControllerTestCase(MockerTestCase): |
342 | """Test the wizard controller.""" |
343 | |
344 | @@ -456,13 +477,29 @@ |
345 | self.mocker.replay() |
346 | self.controller.registration_success_callback(app_name, email) |
347 | |
348 | + def test_show_success_message(self): |
349 | + """Test that the correct page will be shown.""" |
350 | + success_page_id = 0 |
351 | + # the buttons layout we expect to have |
352 | + buttons_layout = [] |
353 | + buttons_layout.append(QWizard.Stretch) |
354 | + buttons_layout.append(QWizard.FinishButton) |
355 | + self.view.success_page_id |
356 | + self.mocker.result(success_page_id) |
357 | + self.view.currentPage() |
358 | + self.mocker.result(self.view) |
359 | + self.view.next = success_page_id |
360 | + self.view.next() |
361 | + self.view.setButtonLayout(buttons_layout) |
362 | + self.mocker.replay() |
363 | + self.controller.show_success_message(self.view) |
364 | + |
365 | def test_setup_ui(self): |
366 | """Test that the ui is connect.""" |
367 | self.view.button(QWizard.CancelButton) |
368 | self.mocker.result(self.view) |
369 | self.view.clicked.connect(MATCH(callable)) |
370 | - self.view.loginSuccess.connect(self.controller.on_login_success) |
371 | - self.view.registrationSuccess.connect( |
372 | - self.controller.on_registration_success) |
373 | + self.view.loginSuccess.connect(MATCH(callable)) |
374 | + self.view.registrationSuccess.connect(MATCH(callable)) |
375 | self.mocker.replay() |
376 | self.controller.setupUi(self.view) |