Merge lp:~diegosarmentero/ubuntu-sso-client/pass-recover into lp:ubuntu-sso-client

Proposed by Diego Sarmentero
Status: Merged
Approved by: Diego Sarmentero
Approved revision: 796
Merged at revision: 798
Proposed branch: lp:~diegosarmentero/ubuntu-sso-client/pass-recover
Merge into: lp:ubuntu-sso-client
Diff against target: 179 lines (+102/-3)
2 files modified
ubuntu_sso/qt/controllers.py (+10/-2)
ubuntu_sso/qt/tests/test_controllers.py (+92/-1)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntu-sso-client/pass-recover
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+77346@code.launchpad.net

Commit message

Fixed: Password recovery on Windows client gives error (LP: #853794).

Description of the change

Fixed: Password recovery on Windows client gives error (LP: #853794).

And add some functions to complete the email field from the next page if the user already complete that in the previous page.

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

E0102:1029:FakeLineEdit: class already defined line 199
C0103:1041:FakeLineEdit.setText: Invalid name "setText" (should match ([a-z_][a-z0-9_]{2,79}$|setUp|tearDown))

review: Needs Fixing
796. By Diego Sarmentero

Fixed lint issues.

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

Looks and works great.

review: Approve
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 'ubuntu_sso/qt/controllers.py'
2--- ubuntu_sso/qt/controllers.py 2011-09-22 17:03:50 +0000
3+++ ubuntu_sso/qt/controllers.py 2011-09-28 17:58:19 +0000
4@@ -250,6 +250,8 @@
5 def on_forgotten_password(self):
6 """Show the user the forgotten password page."""
7 logger.info('Forgotten password')
8+ email = unicode(self.view.ui.email_edit.text())
9+ self.view.wizard().forgotten.ui.email_line_edit.setText(email)
10 self.view.next = self.view.wizard().forgotten_password_page_id
11 self.view.wizard().next()
12
13@@ -653,7 +655,8 @@
14 def pageInitialized(self):
15 """Set the initial state of ForgottenPassword page."""
16 self.view.send_button.setDefault(True)
17- self.view.send_button.setEnabled(False)
18+ enabled = not self.view.ui.email_line_edit.text().isEmpty()
19+ self.view.send_button.setEnabled(enabled)
20 # The style from this property come from the Wizard
21 self.view.send_button.setProperty("DisabledState",
22 not self.view.send_button.isEnabled())
23@@ -826,6 +829,11 @@
24
25 def on_password_changed(self, app_name, result):
26 """Let user know that the password was changed."""
27+ email = unicode(self.view.wizard().forgotten.ui.email_line_edit.text())
28+ self.view.wizard().current_user.ui.email_edit.setText(email)
29+ self.view.wizard().overlay.hide()
30+ self.view.wizard().back()
31+ self.view.wizard().back()
32
33 def on_password_change_error(self, app_name, error):
34 """Let the user know that there was an error."""
35@@ -837,7 +845,7 @@
36 def set_new_password(self):
37 """Request a new password to be set."""
38 app_name = self.view.wizard().app_name
39- email = unicode(self.view.wizard().field('email_address').toString())
40+ email = unicode(self.view.wizard().forgotten.ui.email_line_edit.text())
41 code = unicode(self.view.ui.reset_code_line_edit.text())
42 password = unicode(self.view.ui.password_line_edit.text())
43 logger.info('Settig new password for %s and email %s with code %s',
44
45=== modified file 'ubuntu_sso/qt/tests/test_controllers.py'
46--- ubuntu_sso/qt/tests/test_controllers.py 2011-09-26 19:18:26 +0000
47+++ ubuntu_sso/qt/tests/test_controllers.py 2011-09-28 17:58:19 +0000
48@@ -23,6 +23,7 @@
49
50 from mocker import MATCH, MockerTestCase
51 from PyQt4.QtGui import QWizard
52+from PyQt4.QtCore import QString
53
54 # pylint: disable=F0401
55 try:
56@@ -1111,6 +1112,26 @@
57 self.controller.setupUi(self.view)
58
59
60+class FakeLineEditForForgottenPage(object):
61+
62+ """Fake Line Edit"""
63+
64+ def __init__(self):
65+ """Initilize object."""
66+ self.email_text = QString()
67+
68+ def text(self):
69+ """Fake text for QLineEdit."""
70+ return self.email_text
71+
72+ # setText is inherited
73+ # pylint: disable=C0103
74+ def setText(self, text):
75+ """Fake setText for QLineEdit."""
76+ self.email_text = QString(text)
77+ # pylint: enable=C0103
78+
79+
80 class FakeForgottenPasswordPage(FakePageUiStyle):
81 """Fake the page."""
82
83@@ -1121,6 +1142,7 @@
84 self.email_widget = FakePageUiStyle()
85 self.forgotted_password_intro_label = FakePageUiStyle()
86 self.try_again_widget = FakePageUiStyle()
87+ self.email_line_edit = FakeLineEditForForgottenPage()
88
89
90 class ForgottenPasswordControllerValidationTest(BaseTestCase):
91@@ -1146,6 +1168,19 @@
92 self.assertTrue(self.controller.view.properties.get('unpolish', False))
93 self.assertTrue(self.controller.view.properties.get('polish', False))
94
95+ def test_page_initialized_with_text(self):
96+ """Test the initial state of the page when it is loaded."""
97+ self.controller.view.email_line_edit.setText('mail@mail.com')
98+ self.controller.pageInitialized()
99+ self.assertTrue(self.controller.view.send_button.enabled())
100+ self.assertTrue(
101+ self.controller.view.send_button.properties['default'])
102+ self.assertTrue("DisabledState" in self.controller.view.properties)
103+ self.assertEqual(self.controller.view.properties["DisabledState"],
104+ not self.controller.view.send_button.enabled())
105+ self.assertTrue(self.controller.view.properties.get('unpolish', False))
106+ self.assertTrue(self.controller.view.properties.get('polish', False))
107+
108 def test_valid(self):
109 """The submit button should be enabled with a valid email."""
110 self.controller.view.email_address_line_edit.setText("a@b")
111@@ -1338,7 +1373,7 @@
112 password = 'password'
113 self.view.wizard().app_name
114 self.mocker.result(app_name)
115- self.view.wizard().field('email_address').toString()
116+ unicode(self.view.wizard().forgotten.ui.email_line_edit.text())
117 self.mocker.result(email)
118 self.view.ui.reset_code_line_edit.text()
119 self.mocker.result(code)
120@@ -1445,3 +1480,59 @@
121 self.controller.view.confirm_password_line_edit.setText("1234567")
122 self.controller._validate()
123 self.assertFalse(self.controller.view.reset_password_button.enabled())
124+
125+
126+class FakeWizardForResetPassword(object):
127+
128+ """Fake Wizard for ResetPasswordController."""
129+
130+ def __init__(self):
131+ self.current_user = self
132+ self.ui = self
133+ self.email_edit = self
134+ self.email_line_edit = self
135+ self.forgotten = self
136+ self.overlay = self
137+ self.count_back = 0
138+ self.hide_value = False
139+ self.text_value = 'mail@mail.com'
140+
141+ def wizard(self):
142+ """Fake wizard function for view."""
143+ return self
144+
145+ def back(self):
146+ """Fake back for wizard."""
147+ self.count_back += 1
148+
149+ def hide(self):
150+ """Fake hide for overlay."""
151+ self.hide_value = True
152+
153+ def text(self):
154+ """Fake text for QLineEdit."""
155+ return self.text_value
156+
157+ # pylint: disable=C0103
158+ def setText(self, text):
159+ """Fake setText for QLineEdit."""
160+ self.text_value = text
161+ # pylint: enable=C0103
162+
163+
164+class ResetPasswordControllerRealControllerTest(BaseTestCase):
165+
166+ """Tests for ResetPasswordController, but without Mocker."""
167+
168+ def setUp(self):
169+ """Setup test."""
170+ super(ResetPasswordControllerRealControllerTest, self).setUp()
171+ self.controller = ResetPasswordController()
172+ self.controller.view = FakeWizardForResetPassword()
173+
174+ def test_on_password_changed(self):
175+ """Test that on_password_changed execute the proper operation."""
176+ self.controller.on_password_changed('app_name', '')
177+ self.assertTrue(self.controller.view.hide_value)
178+ self.assertEqual(self.controller.view.count_back, 2)
179+ self.assertEqual(self.controller.view.text_value, 'mail@mail.com')

Subscribers

People subscribed via source and target branches