[CWEP002 migration] support drop_relation_type/drop_relation_definition/drop_attribute for computed attributes
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 22 Jul 2014 11:00:21 +0200
changeset 9970 671bbfed459b
parent 9969 0f64ef873f7a
child 9971 5e44dd9dde6b
[CWEP002 migration] support drop_relation_type/drop_relation_definition/drop_attribute for computed attributes
server/test/datacomputed/schema.py
server/test/unittest_migractions.py
--- a/server/test/datacomputed/schema.py	Thu Aug 28 18:31:18 2014 +0200
+++ b/server/test/datacomputed/schema.py	Tue Jul 22 11:00:21 2014 +0200
@@ -38,7 +38,7 @@
 
 class Note(EntityType):
     note = Int()
-
+    note20 = Int(formula='Any N*20 WHERE X note N')
 
 class concerns(RelationDefinition):
     subject = 'Note'
--- a/server/test/unittest_migractions.py	Thu Aug 28 18:31:18 2014 +0200
+++ b/server/test/unittest_migractions.py	Tue Jul 22 11:00:21 2014 +0200
@@ -799,6 +799,31 @@
             self.assertIn('score', self.schema)
             self.assert_score_initialized(mh)
 
+    def assert_computed_attribute_dropped(self):
+        self.assertNotIn('note20', self.schema)
+        # DROP COLUMN not supported by sqlite
+        #with self.mh() as (cnx, mh):
+        #    fields = self.table_schema(mh, '%sNote' % SQL_PREFIX)
+        #self.assertNotIn('%snote20' % SQL_PREFIX, fields)
+
+    def test_computed_attribute_drop_type(self):
+        self.assertIn('note20', self.schema)
+        with self.mh() as (cnx, mh):
+            mh.cmd_drop_relation_type('note20')
+        self.assert_computed_attribute_dropped()
+
+    def test_computed_attribute_drop_relation_definition(self):
+        self.assertIn('note20', self.schema)
+        with self.mh() as (cnx, mh):
+            mh.cmd_drop_relation_definition('Note', 'note20', 'Int')
+        self.assert_computed_attribute_dropped()
+
+    def test_computed_attribute_drop_attribute(self):
+        self.assertIn('note20', self.schema)
+        with self.mh() as (cnx, mh):
+            mh.cmd_drop_attribute('Note', 'note20')
+        self.assert_computed_attribute_dropped()
+
 
 if __name__ == '__main__':
     unittest_main()