Commit ed78df21 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

remove duplicated method and update test to follow recent change in cw#default

parent fc85994a71ac
......@@ -32,12 +32,13 @@ class RegistrationTC(CubicWebTC):
def _check_error(self, req, path,
expected_path='registration',
expected_errors=None,
expected_params=None,
expected_msg=None,
expected_formvalues=None):
path, params = self.expect_redirect_publish(req, path)
self.assertEqual(path, expected_path)
self.assertEqual(params, expected_params or {})
forminfo = req.get_session_data('registration')
if expected_msg:
self.assertMessageEqual(req, params, expected_msg)
forminfo = req.session.data.get('registration')
if forminfo is None:
self.failIf(expected_errors or expected_formvalues)
else:
......@@ -76,7 +77,7 @@ class RegistrationTC(CubicWebTC):
req.session.data['captcha'] = self.captcha_value
path, params = self.expect_redirect_publish(req, 'registration_sendmail')
self.assertEqual(path, '')
self.assertEqual(params, {'__message': 'Your registration email has been sent. Follow instructions in there to activate your account.'})
self.assertMessageEqual(req, params, 'Your registration email has been sent. Follow instructions in there to activate your account.')
# check email contains activation url...
URL_RE = re.compile('(%s[^.]+)\.' % self.config['base-url'])
text = MAILBOX[-1].message.get_payload(decode=True)
......@@ -119,7 +120,7 @@ class RegistrationTC(CubicWebTC):
req = self._confirm_req()
path, params = self.expect_redirect_publish(req, 'registration_confirm')
self.assertEqual(path, '')
self.assertEqual(params, {'__message': u'Congratulations, your registration is complete. Welcome %(firstname-subject)s %(surname-subject)s !' % self.data})
self.assertMessageEqual(req, params, 'Congratulations, your registration is complete. Welcome %(firstname-subject)s %(surname-subject)s !' % self.data)
self.restore_connection()
rset = self.execute('Any U WHERE U login %(login)s, U firstname %(firstname)s, '
'U surname %(surname)s, U use_email M, M address %(email_address)s',
......@@ -127,24 +128,6 @@ class RegistrationTC(CubicWebTC):
for k, v in self.data.items()))
self.failUnless(rset.rowcount)
def _check_error(self, req, path,
expected_path='registration',
expected_errors=None,
expected_params=None,
expected_formvalues=None):
path, params = self.expect_redirect_publish(req, path)
self.assertEqual(path, expected_path)
self.assertEqual(params, expected_params or {})
forminfo = req.session.data.get('registration')
if forminfo is None:
self.failIf(expected_errors or expected_formvalues)
else:
self.assertEqual(forminfo['eidmap'], {})
self.assertEqual(forminfo['values'], expected_formvalues or {})
error = forminfo['error']
self.assertEqual(error.entity, None)
self.assertEqual(error.errors, expected_errors or {})
def test_confirm_failure_login_already_used(self):
# try to recreate a 'admin' user.
req = self._confirm_req(overriden={'login-subject': 'admin'})
......@@ -158,8 +141,7 @@ class RegistrationTC(CubicWebTC):
def test_confirm_failure_invalid_data(self):
req = self._confirm_req('dummykey')
self._check_error(req, 'registration_confirm', 'register',
expected_params={'__message': 'Invalid registration data. '
'Please try registering again.'})
expected_msg='Invalid registration data. Please try registering again.')
self._check_user_not_created()
def test_confirm_failure_email_already_used(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment