113 self.assertEqual(len(rset), 1) |
113 self.assertEqual(len(rset), 1) |
114 self.assertEqual(rset.get_entity(0, 0).reverse_parts[0].messageid, '<2345>') |
114 self.assertEqual(rset.get_entity(0, 0).reverse_parts[0].messageid, '<2345>') |
115 |
115 |
116 def test_unsatisfied_constraints(self): |
116 def test_unsatisfied_constraints(self): |
117 releid = self.execute('SET U in_group G WHERE G name "owners", U login "admin"')[0][0] |
117 releid = self.execute('SET U in_group G WHERE G name "owners", U login "admin"')[0][0] |
118 ex = self.assertRaises(ValidationError, self.commit) |
118 with self.assertRaises(ValidationError) as cm: |
119 self.assertEqual(ex.errors, |
119 self.commit() |
|
120 self.assertEqual(cm.exception.errors, |
120 {'in_group-object': u'RQLConstraint NOT O name "owners" failed'}) |
121 {'in_group-object': u'RQLConstraint NOT O name "owners" failed'}) |
121 |
122 |
122 def test_html_tidy_hook(self): |
123 def test_html_tidy_hook(self): |
123 req = self.request() |
124 req = self.request() |
124 entity = req.create_entity('Workflow', name=u'wf1', description_format=u'text/html', |
125 entity = req.create_entity('Workflow', name=u'wf1', description_format=u'text/html', |
225 |
226 |
226 |
227 |
227 class CWPropertyHooksTC(CubicWebTC): |
228 class CWPropertyHooksTC(CubicWebTC): |
228 |
229 |
229 def test_unexistant_eproperty(self): |
230 def test_unexistant_eproperty(self): |
230 ex = self.assertRaises(ValidationError, |
231 with self.assertRaises(ValidationError) as cm: |
231 self.execute, 'INSERT CWProperty X: X pkey "bla.bla", X value "hop", X for_user U') |
232 self.execute('INSERT CWProperty X: X pkey "bla.bla", X value "hop", X for_user U') |
232 self.assertEqual(ex.errors, {'pkey-subject': 'unknown property key bla.bla'}) |
233 self.assertEqual(cm.exception.errors, {'pkey-subject': 'unknown property key bla.bla'}) |
233 ex = self.assertRaises(ValidationError, |
234 with self.assertRaises(ValidationError) as cm: |
234 self.execute, 'INSERT CWProperty X: X pkey "bla.bla", X value "hop"') |
235 self.execute('INSERT CWProperty X: X pkey "bla.bla", X value "hop"') |
235 self.assertEqual(ex.errors, {'pkey-subject': 'unknown property key bla.bla'}) |
236 self.assertEqual(cm.exception.errors, {'pkey-subject': 'unknown property key bla.bla'}) |
236 |
237 |
237 def test_site_wide_eproperty(self): |
238 def test_site_wide_eproperty(self): |
238 ex = self.assertRaises(ValidationError, |
239 with self.assertRaises(ValidationError) as cm: |
239 self.execute, 'INSERT CWProperty X: X pkey "ui.site-title", X value "hop", X for_user U') |
240 self.execute('INSERT CWProperty X: X pkey "ui.site-title", X value "hop", X for_user U') |
240 self.assertEqual(ex.errors, {'for_user-subject': "site-wide property can't be set for user"}) |
241 self.assertEqual(cm.exception.errors, {'for_user-subject': "site-wide property can't be set for user"}) |
241 |
242 |
242 def test_bad_type_eproperty(self): |
243 def test_bad_type_eproperty(self): |
243 ex = self.assertRaises(ValidationError, |
244 with self.assertRaises(ValidationError) as cm: |
244 self.execute, 'INSERT CWProperty X: X pkey "ui.language", X value "hop", X for_user U') |
245 self.execute('INSERT CWProperty X: X pkey "ui.language", X value "hop", X for_user U') |
245 self.assertEqual(ex.errors, {'value-subject': u'unauthorized value'}) |
246 self.assertEqual(cm.exception.errors, {'value-subject': u'unauthorized value'}) |
246 ex = self.assertRaises(ValidationError, |
247 with self.assertRaises(ValidationError) as cm: |
247 self.execute, 'INSERT CWProperty X: X pkey "ui.language", X value "hop"') |
248 self.execute('INSERT CWProperty X: X pkey "ui.language", X value "hop"') |
248 self.assertEqual(ex.errors, {'value-subject': u'unauthorized value'}) |
249 self.assertEqual(cm.exception.errors, {'value-subject': u'unauthorized value'}) |
249 |
250 |
250 |
251 |
251 class SchemaHooksTC(CubicWebTC): |
252 class SchemaHooksTC(CubicWebTC): |
252 |
253 |
253 def test_duplicate_etype_error(self): |
254 def test_duplicate_etype_error(self): |