20 |
20 |
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 six import text_type |
|
26 |
25 from cubicweb import ValidationError |
27 from cubicweb import ValidationError |
26 from cubicweb.devtools.testlib import CubicWebTC |
28 from cubicweb.devtools.testlib import CubicWebTC |
27 |
29 |
28 class CWPropertyHooksTC(CubicWebTC): |
30 class CWPropertyHooksTC(CubicWebTC): |
29 |
31 |
30 def test_unexistant_cwproperty(self): |
32 def test_unexistant_cwproperty(self): |
31 with self.admin_access.web_request() as req: |
33 with self.admin_access.web_request() as req: |
32 with self.assertRaises(ValidationError) as cm: |
34 with self.assertRaises(ValidationError) as cm: |
33 req.execute('INSERT CWProperty X: X pkey "bla.bla", ' |
35 req.execute('INSERT CWProperty X: X pkey "bla.bla", ' |
34 'X value "hop", X for_user U') |
36 'X value "hop", X for_user U') |
35 cm.exception.translate(unicode) |
37 cm.exception.translate(text_type) |
36 self.assertEqual(cm.exception.errors, |
38 self.assertEqual(cm.exception.errors, |
37 {'pkey-subject': 'unknown property key bla.bla'}) |
39 {'pkey-subject': 'unknown property key bla.bla'}) |
38 |
40 |
39 with self.assertRaises(ValidationError) as cm: |
41 with self.assertRaises(ValidationError) as cm: |
40 req.execute('INSERT CWProperty X: X pkey "bla.bla", X value "hop"') |
42 req.execute('INSERT CWProperty X: X pkey "bla.bla", X value "hop"') |
41 cm.exception.translate(unicode) |
43 cm.exception.translate(text_type) |
42 self.assertEqual(cm.exception.errors, |
44 self.assertEqual(cm.exception.errors, |
43 {'pkey-subject': 'unknown property key bla.bla'}) |
45 {'pkey-subject': 'unknown property key bla.bla'}) |
44 |
46 |
45 def test_site_wide_cwproperty(self): |
47 def test_site_wide_cwproperty(self): |
46 with self.admin_access.web_request() as req: |
48 with self.admin_access.web_request() as req: |