Merge lp:~elopio/u1-test-utils/improve_login_from_redirect_error_message into lp:u1-test-utils

Proposed by Leo Arias
Status: Merged
Approved by: Natalia Bidart
Approved revision: 65
Merged at revision: 63
Proposed branch: lp:~elopio/u1-test-utils/improve_login_from_redirect_error_message
Merge into: lp:u1-test-utils
Diff against target: 84 lines (+63/-0)
2 files modified
u1testutils/sso/selftests/unit/test_sst_helpers.py (+40/-0)
u1testutils/sso/sst/pages.py (+23/-0)
To merge this branch: bzr merge lp:~elopio/u1-test-utils/improve_login_from_redirect_error_message
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Review via email: mp+162650@code.launchpad.net

Commit message

Added a suggestion for the most common cause of LogIn errors.

To post a comment you must log in.
64. By Leo Arias

Added the test for the suggestion.

65. By Leo Arias

Improved the suggestion condition.

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

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'u1testutils/sso/selftests/unit/test_sst_helpers.py'
--- u1testutils/sso/selftests/unit/test_sst_helpers.py 1970-01-01 00:00:00 +0000
+++ u1testutils/sso/selftests/unit/test_sst_helpers.py 2013-05-06 21:32:27 +0000
@@ -0,0 +1,40 @@
1# Copyright 2013 Canonical Ltd.
2#
3# This program is free software: you can redistribute it and/or modify it
4# under the terms of the GNU Lesser General Public License version 3, as
5# published by the Free Software Foundation.
6#
7# This program is distributed in the hope that it will be useful, but
8# WITHOUT ANY WARRANTY; without even the implied warranties of
9# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
10# PURPOSE. See the GNU Lesser General Public License for more details.
11#
12# You should have received a copy of the GNU General Public License along
13# with this program. If not, see <http://www.gnu.org/licenses/
14
15import mock
16
17import u1testutils.logging
18from u1testutils.sso.sst import pages
19
20
21class LogInFromRedirectTestCase(u1testutils.logging.LogHandlerTestCase):
22
23 def test_site_without_rpconfig(self):
24 with mock.patch.object(pages.LogInFromRedirect, 'assert_page_is_open'):
25 page = pages.LogInFromRedirect()
26
27 with mock.patch('sst.actions.get_elements') as mock_elements:
28 mock_elements.return_value = []
29 headings2 = ['Log in to Ubuntu Single Sign On', 'Are you new?']
30 for heading in headings2:
31 mock_heading_element = mock.Mock()
32 mock_heading_element.text = heading
33 mock_elements.return_value.append(mock_heading_element)
34 with self.assertRaises(AssertionError):
35 page.assert_headings2()
36 self.assertLogLevelContains(
37 'ERROR',
38 'Please check that you are logging in from a server with '
39 'an rpconfig on SSO. Otherwise, the headings in the page '
40 'will not be the ones we expect.')
041
=== modified file 'u1testutils/sso/sst/pages.py'
--- u1testutils/sso/sst/pages.py 2013-05-01 14:56:05 +0000
+++ u1testutils/sso/sst/pages.py 2013-05-06 21:32:27 +0000
@@ -21,6 +21,9 @@
21from u1testutils.sst import log_action21from u1testutils.sst import log_action
2222
2323
24logger = logging.getLogger('User test')
25
26
24class LogIn(u1testutils.sst.Page):27class LogIn(u1testutils.sst.Page):
25 """Log in page of the Ubuntu Single Sign On website.28 """Log in page of the Ubuntu Single Sign On website.
2629
@@ -107,6 +110,26 @@
107 self._click_create_new_account()110 self._click_create_new_account()
108 return CreateAccountFromRedirect()111 return CreateAccountFromRedirect()
109112
113 def assert_headings2(self):
114 """Assert the h2 elements of the page.
115
116 This method wraps the one from the parent class in order to log
117 suggestions about the most common environment errors that make it fail.
118
119 """
120 try:
121 super(LogInFromRedirect, self).assert_headings2()
122 except AssertionError:
123 heading2_without_rpconfig = 'Log in to Ubuntu Single Sign On'
124 if heading2_without_rpconfig in self._get_elements_text('h2'):
125 suggestion = (
126 'Please check that you are logging in from a server with '
127 'an rpconfig on SSO. Otherwise, the headings in the page '
128 'will not be the ones we expect.'
129 )
130 logger.error(suggestion)
131 raise
132
110133
111class PageWithAnonymousSubheader(u1testutils.sst.Page):134class PageWithAnonymousSubheader(u1testutils.sst.Page):
112135

Subscribers

People subscribed via source and target branches

to all changes: