equal
deleted
inserted
replaced
21 Note: |
21 Note: |
22 syncschema.py hooks are mostly tested in server/test/unittest_migrations.py |
22 syncschema.py hooks are mostly tested in server/test/unittest_migrations.py |
23 """ |
23 """ |
24 |
24 |
25 from datetime import datetime |
25 from datetime import datetime |
26 |
|
27 from six import text_type |
|
28 |
26 |
29 from pytz import utc |
27 from pytz import utc |
30 |
28 |
31 from cubicweb import ValidationError |
29 from cubicweb import ValidationError |
32 from cubicweb.devtools.testlib import CubicWebTC |
30 from cubicweb.devtools.testlib import CubicWebTC |
209 def test_validation_unique_constraint(self): |
207 def test_validation_unique_constraint(self): |
210 with self.admin_access.repo_cnx() as cnx: |
208 with self.admin_access.repo_cnx() as cnx: |
211 with self.assertRaises(ValidationError) as cm: |
209 with self.assertRaises(ValidationError) as cm: |
212 cnx.execute('INSERT CWUser X: X login "admin", X upassword "admin"') |
210 cnx.execute('INSERT CWUser X: X login "admin", X upassword "admin"') |
213 ex = cm.exception |
211 ex = cm.exception |
214 ex.translate(text_type) |
212 ex.translate(str) |
215 self.assertIsInstance(ex.entity, int) |
213 self.assertIsInstance(ex.entity, int) |
216 self.assertEqual(ex.errors, |
214 self.assertEqual(ex.errors, |
217 {'': u'some relations violate a unicity constraint', |
215 {'': u'some relations violate a unicity constraint', |
218 'login': u'login is part of violated unicity constraint'}) |
216 'login': u'login is part of violated unicity constraint'}) |
219 |
217 |