hooks/test/unittest_hooks.py
branchstable
changeset 7192 9e92c8558fea
parent 6969 c527de85ea61
child 7244 a918f76441ce
equal deleted inserted replaced
7191:1e2d8e4d2c7b 7192:9e92c8558fea
   143         self.execute('DELETE EmailAddress X WHERE X eid %s' % eid)
   143         self.execute('DELETE EmailAddress X WHERE X eid %s' % eid)
   144         self.commit()
   144         self.commit()
   145         self.failIf(self.execute('Any X WHERE X created_by Y, X eid >= %(x)s', {'x': eid}))
   145         self.failIf(self.execute('Any X WHERE X created_by Y, X eid >= %(x)s', {'x': eid}))
   146 
   146 
   147 
   147 
   148 class CWPropertyHooksTC(CubicWebTC):
       
   149 
       
   150     def test_unexistant_eproperty(self):
       
   151         with self.assertRaises(ValidationError) as cm:
       
   152             self.execute('INSERT CWProperty X: X pkey "bla.bla", X value "hop", X for_user U')
       
   153         self.assertEqual(cm.exception.errors, {'pkey-subject': 'unknown property key bla.bla'})
       
   154         with self.assertRaises(ValidationError) as cm:
       
   155             self.execute('INSERT CWProperty X: X pkey "bla.bla", X value "hop"')
       
   156         self.assertEqual(cm.exception.errors, {'pkey-subject': 'unknown property key bla.bla'})
       
   157 
       
   158     def test_site_wide_eproperty(self):
       
   159         with self.assertRaises(ValidationError) as cm:
       
   160             self.execute('INSERT CWProperty X: X pkey "ui.site-title", X value "hop", X for_user U')
       
   161         self.assertEqual(cm.exception.errors, {'for_user-subject': "site-wide property can't be set for user"})
       
   162 
       
   163     def test_bad_type_eproperty(self):
       
   164         with self.assertRaises(ValidationError) as cm:
       
   165             self.execute('INSERT CWProperty X: X pkey "ui.language", X value "hop", X for_user U')
       
   166         self.assertEqual(cm.exception.errors, {'value-subject': u'unauthorized value'})
       
   167         with self.assertRaises(ValidationError) as cm:
       
   168             self.execute('INSERT CWProperty X: X pkey "ui.language", X value "hop"')
       
   169         self.assertEqual(cm.exception.errors, {'value-subject': u'unauthorized value'})
       
   170 
       
   171 
   148 
   172 class SchemaHooksTC(CubicWebTC):
   149 class SchemaHooksTC(CubicWebTC):
   173 
   150 
   174     def test_duplicate_etype_error(self):
   151     def test_duplicate_etype_error(self):
   175         # check we can't add a CWEType or CWRType entity if it already exists one
   152         # check we can't add a CWEType or CWRType entity if it already exists one