cubicweb/hooks/test/unittest_syncsession.py
changeset 12567 26744ad37953
parent 12126 be8636d12afd
equal deleted inserted replaced
12566:6b3523f81f42 12567:26744ad37953
    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 
       
    27 from cubicweb import ValidationError
    25 from cubicweb import ValidationError
    28 from cubicweb.devtools.testlib import CubicWebTC
    26 from cubicweb.devtools.testlib import CubicWebTC
    29 
    27 
    30 
    28 
    31 class CWPropertyHooksTC(CubicWebTC):
    29 class CWPropertyHooksTC(CubicWebTC):
    33     def test_unexistant_cwproperty(self):
    31     def test_unexistant_cwproperty(self):
    34         with self.admin_access.web_request() as req:
    32         with self.admin_access.web_request() as req:
    35             with self.assertRaises(ValidationError) as cm:
    33             with self.assertRaises(ValidationError) as cm:
    36                 req.execute('INSERT CWProperty X: X pkey "bla.bla", '
    34                 req.execute('INSERT CWProperty X: X pkey "bla.bla", '
    37                             'X value "hop", X for_user U')
    35                             'X value "hop", X for_user U')
    38             cm.exception.translate(text_type)
    36             cm.exception.translate(str)
    39             self.assertEqual(cm.exception.errors,
    37             self.assertEqual(cm.exception.errors,
    40                              {'pkey-subject': 'unknown property key bla.bla'})
    38                              {'pkey-subject': 'unknown property key bla.bla'})
    41 
    39 
    42             with self.assertRaises(ValidationError) as cm:
    40             with self.assertRaises(ValidationError) as cm:
    43                 req.execute('INSERT CWProperty X: X pkey "bla.bla", X value "hop"')
    41                 req.execute('INSERT CWProperty X: X pkey "bla.bla", X value "hop"')
    44             cm.exception.translate(text_type)
    42             cm.exception.translate(str)
    45             self.assertEqual(cm.exception.errors,
    43             self.assertEqual(cm.exception.errors,
    46                              {'pkey-subject': 'unknown property key bla.bla'})
    44                              {'pkey-subject': 'unknown property key bla.bla'})
    47 
    45 
    48     def test_site_wide_cwproperty(self):
    46     def test_site_wide_cwproperty(self):
    49         with self.admin_access.web_request() as req:
    47         with self.admin_access.web_request() as req: