server/test/unittest_migractions.py
changeset 9964 f4a3ee05cf9d
parent 9963 5531f5577b50
child 9969 0f64ef873f7a
--- a/server/test/unittest_migractions.py	Thu Aug 28 08:02:15 2014 +0200
+++ b/server/test/unittest_migractions.py	Thu Aug 28 07:44:29 2014 +0200
@@ -735,6 +735,26 @@
             mh.cmd_drop_relation_type('notes')
         self.assertNotIn('notes', self.schema)
 
+    def test_computed_relation_sync_schema_props_perms(self):
+        self.assertIn('whatever', self.schema)
+        with self.mh() as (cnx, mh):
+            mh.cmd_sync_schema_props_perms('whatever')
+            self.assertEqual(self.schema['whatever'].rule,
+                             'S employees E, O associates E')
+            self.assertEqual(self.schema['whatever'].objects(), ('Company',))
+            self.assertEqual(self.schema['whatever'].subjects(), ('Company',))
+            self.assertFalse(self.table_sql(mh, 'whatever_relation'))
+
+    def test_computed_relation_sync_schema_props_perms_on_rdef(self):
+        self.assertIn('whatever', self.schema)
+        with self.mh() as (cnx, mh):
+            with self.assertRaises(ExecutionError) as exc:
+                mh.cmd_sync_schema_props_perms(
+                    ('Company', 'whatever', 'Person'))
+        self.assertEqual(str(exc.exception),
+                         'Cannot synchronize a relation definition for a computed '
+                         'relation (whatever)')
+
 
 if __name__ == '__main__':
     unittest_main()