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

update to unittest2 api

--HG--
branch : stable
parent 93c5cbd03a89
......@@ -35,17 +35,17 @@ class RegistrationTC(CubicWebTC):
expected_params=None,
expected_formvalues=None):
path, params = self.expect_redirect_publish(req, path)
self.assertEquals(path, expected_path)
self.assertEquals(params, expected_params or {})
self.assertEqual(path, expected_path)
self.assertEqual(params, expected_params or {})
forminfo = req.get_session_data('registration')
if forminfo is None:
self.failIf(expected_errors or expected_formvalues)
else:
self.assertEquals(forminfo['eidmap'], {})
self.assertEquals(forminfo['values'], expected_formvalues or {})
self.assertEqual(forminfo['eidmap'], {})
self.assertEqual(forminfo['values'], expected_formvalues or {})
error = forminfo['error']
self.assertEquals(error.entity, None)
self.assertEquals(error.errors, expected_errors or {})
self.assertEqual(error.entity, None)
self.assertEqual(error.errors, expected_errors or {})
def _posted_form(self, *skipkeys):
data = self.data.copy()
......@@ -63,11 +63,11 @@ class RegistrationTC(CubicWebTC):
# check form field names
names = pageinfo.etree.xpath('//ns:form[@id="registrationForm"]//ns:input[@type!="hidden"]/@name',
namespaces=ns)
self.assertEquals(set(names), set(self.data))
self.assertEqual(set(names), set(self.data))
# check form field value
firstname = pageinfo.etree.xpath('//ns:input[@name="firstname-subject"]/@value',
namespaces=ns)
self.assertEquals(firstname, [req.form['firstname-subject']])
self.assertEqual(firstname, [req.form['firstname-subject']])
def test_send_mail_ok(self):
self.login('anon')
......@@ -75,8 +75,8 @@ class RegistrationTC(CubicWebTC):
req.form = self._posted_form()
req.session.data['captcha'] = self.captcha_value
path, params = self.expect_redirect_publish(req, 'registration_sendmail')
self.assertEquals(path, '')
self.assertEquals(params, {'__message': 'Your registration email has been sent. Follow instructions in there to activate your account.'})
self.assertEqual(path, '')
self.assertEqual(params, {'__message': '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)
......@@ -84,7 +84,7 @@ class RegistrationTC(CubicWebTC):
# ... and the registration key contains all data
key = dict(cgi.parse_qsl(urlparse.urlsplit(url)[3]))['key']
d = self._posted_form('upassword-subject-confirm')
self.assertDictEquals(decrypt(key, self.config['registration-cypher-seed']), d)
self.assertDictEqual(decrypt(key, self.config['registration-cypher-seed']), d)
def test_send_mail_failure(self):
for param, msg, val in (('login-subject', 'required field', None),
......@@ -101,7 +101,7 @@ class RegistrationTC(CubicWebTC):
self._check_error(req, 'registration_sendmail',
expected_formvalues=req.form,
expected_errors={param: msg})
self.assertEquals(req.session.data.get('captcha'), None)
self.assertEqual(req.session.data.get('captcha'), None)
def _confirm_req(self, key=None, overriden={}):
self.login('anon')
......@@ -118,8 +118,8 @@ class RegistrationTC(CubicWebTC):
def test_confirm_ok(self):
req = self._confirm_req()
path, params = self.expect_redirect_publish(req, 'registration_confirm')
self.assertEquals(path, '')
self.assertEquals(params, {'__message': u'Congratulations, your registration is complete. Welcome %(firstname-subject)s %(surname-subject)s !' % self.data})
self.assertEqual(path, '')
self.assertEqual(params, {'__message': u'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 %(address)s',
......@@ -133,17 +133,17 @@ class RegistrationTC(CubicWebTC):
expected_params=None,
expected_formvalues=None):
path, params = self.expect_redirect_publish(req, path)
self.assertEquals(path, expected_path)
self.assertEquals(params, expected_params or {})
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.assertEquals(forminfo['eidmap'], {})
self.assertEquals(forminfo['values'], expected_formvalues or {})
self.assertEqual(forminfo['eidmap'], {})
self.assertEqual(forminfo['values'], expected_formvalues or {})
error = forminfo['error']
self.assertEquals(error.entity, None)
self.assertEquals(error.errors, expected_errors or {})
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.
......
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