# HG changeset patch # User Sylvain Thénault # Date 1492006316 -7200 # Node ID 0cf35ffde0e4f05c37eea29b54c9cb3d969b2d59 # Parent 0ff0aff4413db58cb3d84f5dc1b80e3a53277f73 [test] Add some tests for hooks.syncsources for parts which are not located in some source's check_config / check_urls method. diff -r 0ff0aff4413d -r 0cf35ffde0e4 cubicweb/hooks/test/unittest_syncsources.py --- a/cubicweb/hooks/test/unittest_syncsources.py Wed Apr 12 16:10:57 2017 +0200 +++ b/cubicweb/hooks/test/unittest_syncsources.py Wed Apr 12 16:11:56 2017 +0200 @@ -22,6 +22,28 @@ class SyncSourcesTC(CubicWebTC): + def test_source_type_unknown(self): + with self.admin_access.cnx() as cnx: + with self.assertRaises(ValidationError) as cm: + cnx.create_entity( + 'CWSource', name=u'source', + type=u'doesnotexit', + parser=u'doestnotmatter', + ) + self.assertIn('Unknown source type', str(cm.exception)) + + def test_cant_delete_system_source(self): + with self.admin_access.cnx() as cnx: + with self.assertRaises(ValidationError) as cm: + cnx.execute('DELETE CWSource X') + self.assertIn('You cannot remove the system source', str(cm.exception)) + + def test_cant_rename_system_source(self): + with self.admin_access.cnx() as cnx: + with self.assertRaises(ValidationError) as cm: + cnx.find('CWSource').one().cw_set(name=u'sexy name') + self.assertIn('You cannot rename the system source', str(cm.exception)) + def test_cant_add_config_system_source(self): with self.admin_access.cnx() as cnx: source = cnx.find('CWSource').one()