# HG changeset patch # User Denis Laxalde # Date 1466674210 -7200 # Node ID 3c8d345d0f3a3aadbc102ecf564a9d1055ac9c2a # Parent a32209aba682f5d08aab1e4a2fd9272bab283177 [test] Add a test for user registration unicity constraint on email diff -r a32209aba682 -r 3c8d345d0f3a cubicweb/sobjects/test/unittest_register_user.py --- a/cubicweb/sobjects/test/unittest_register_user.py Thu Jun 23 11:27:43 2016 +0200 +++ b/cubicweb/sobjects/test/unittest_register_user.py Thu Jun 23 11:30:10 2016 +0200 @@ -30,7 +30,7 @@ login=u'foo2', password=u'bar2', email=u'foo2@bar2.com', firstname=u'Foo2', surname=u'Bar2') - def test_register_user_service_unique(self): + def test_register_user_service_unique_login(self): with self.admin_access.cnx() as cnx: cnx.call_service('register_user', login=u'foo3', password=u'bar3', email=u'foo3@bar3.com', @@ -40,6 +40,19 @@ cnx.call_service('register_user', login=u'foo3', password=u'bar3') + def test_register_user_service_unique_email(self): + with self.admin_access.cnx() as cnx: + cnx.call_service('register_user', login=u'foo3', + password=u'bar3', email=u'foo3@bar3.com', + firstname=u'Foo3', surname=u'Bar3') + with self.assertRaises(ValidationError) as cm: + cnx.call_service('register_user', login=u'foo3@bar3.com', + password=u'bar3') + expected_errors = { + 'login-subject': u'the value "foo3@bar3.com" is already used, use another one', + } + self.assertEqual(cm.exception.errors, expected_errors) + def test_register_user_attributes(self): with self.admin_access.cnx() as cnx: cnx.call_service('register_user', login=u'foo3',