[test] Add some tests for hooks.syncsources 3.25
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 12 Apr 2017 16:11:56 +0200
branch3.25
changeset 12154 0cf35ffde0e4
parent 12153 0ff0aff4413d
child 12155 4ba8fd2cd41a
[test] Add some tests for hooks.syncsources for parts which are not located in some source's check_config / check_urls method.
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()