[serverctl] rename remove_cube to drop_cube (closes #4545093)
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Thu, 23 Oct 2014 15:47:17 +0200
changeset 10107 1ef92a6193a8
parent 10106 3117f1736f00
child 10108 129af90b2364
[serverctl] rename remove_cube to drop_cube (closes #4545093) For the sake of consistency, since commands are currently named: - add_{cube,entity,attribute,relation} - drop_{entity,attribute,relation} - remove_cube
doc/3.20.rst
migration.py
server/migractions.py
server/test/unittest_migractions.py
--- a/doc/3.20.rst	Thu May 15 23:18:17 2014 +0200
+++ b/doc/3.20.rst	Thu Oct 23 15:47:17 2014 +0200
@@ -7,6 +7,7 @@
 * virtual relations: a new ComputedRelation class can be used in
   schema.py; its `rule` attribute is an RQL snippet that defines the new
   relation.
+
 * computed attributes: an attribute can now be defined with a `formula`
   argument (also an RQL snippet); it will be read-only, and updated
   automatically.
@@ -26,6 +27,8 @@
   that of Python's ``csv.reader()``.  The old arguments are still supported
   though deprecated.
 
+* the migration environment's ``remove_cube`` function is now called ``drop_cube``.
+
 
 Deprecated Code Drops
 ----------------------
--- a/migration.py	Thu May 15 23:18:17 2014 +0200
+++ b/migration.py	Thu Oct 23 15:47:17 2014 +0200
@@ -31,6 +31,7 @@
 from logilab.common.configuration import REQUIRED, read_old_config
 from logilab.common.shellutils import ASK
 from logilab.common.changelog import Version
+from logilab.common.deprecation import deprecated
 
 from cubicweb import ConfigurationError, ExecutionError
 from cubicweb.cwconfig import CubicWebConfiguration as cwcfg
@@ -407,7 +408,11 @@
             self.config.add_cubes(newcubes)
         return newcubes
 
+    @deprecated('[3.20] use drop_cube() instead of remove_cube()')
     def cmd_remove_cube(self, cube, removedeps=False):
+        return self.cmd_drop_cube(cube, removedeps)
+
+    def cmd_drop_cube(self, cube, removedeps=False):
         if removedeps:
             toremove = self.config.expand_cubes([cube])
         else:
--- a/server/migractions.py	Thu May 15 23:18:17 2014 +0200
+++ b/server/migractions.py	Thu Oct 23 15:47:17 2014 +0200
@@ -689,8 +689,8 @@
                 self.cmd_exec_event_script('postcreate', cube)
                 self.commit()
 
-    def cmd_remove_cube(self, cube, removedeps=False):
-        removedcubes = super(ServerMigrationHelper, self).cmd_remove_cube(
+    def cmd_drop_cube(self, cube, removedeps=False):
+        removedcubes = super(ServerMigrationHelper, self).cmd_drop_cube(
             cube, removedeps)
         if not removedcubes:
             return
--- a/server/test/unittest_migractions.py	Thu May 15 23:18:17 2014 +0200
+++ b/server/test/unittest_migractions.py	Thu Oct 23 15:47:17 2014 +0200
@@ -554,7 +554,7 @@
                 mh.cmd_set_size_constraint('CWEType', 'description', None)
 
     @tag('longrun')
-    def test_add_remove_cube_and_deps(self):
+    def test_add_drop_cube_and_deps(self):
         with self.mh() as (cnx, mh):
             schema = self.repo.schema
             self.assertEqual(sorted((str(s), str(o)) for s, o in schema['see_also'].rdefs.iterkeys()),
@@ -562,7 +562,7 @@
                                      ('Bookmark', 'Bookmark'), ('Bookmark', 'Note'),
                                      ('Note', 'Note'), ('Note', 'Bookmark')]))
             try:
-                mh.cmd_remove_cube('email', removedeps=True)
+                mh.cmd_drop_cube('email', removedeps=True)
                 # file was there because it's an email dependancy, should have been removed
                 self.assertNotIn('email', self.config.cubes())
                 self.assertNotIn(self.config.cube_dir('email'), self.config.cubes_path())
@@ -613,12 +613,12 @@
 
 
     @tag('longrun')
-    def test_add_remove_cube_no_deps(self):
+    def test_add_drop_cube_no_deps(self):
         with self.mh() as (cnx, mh):
             cubes = set(self.config.cubes())
             schema = self.repo.schema
             try:
-                mh.cmd_remove_cube('email')
+                mh.cmd_drop_cube('email')
                 cubes.remove('email')
                 self.assertNotIn('email', self.config.cubes())
                 self.assertIn('file', self.config.cubes())
@@ -635,10 +635,10 @@
                 # next test may fail complaining of missing tables
                 cnx.commit()
 
-    def test_remove_dep_cube(self):
+    def test_drop_dep_cube(self):
         with self.mh() as (cnx, mh):
             with self.assertRaises(ConfigurationError) as cm:
-                mh.cmd_remove_cube('file')
+                mh.cmd_drop_cube('file')
             self.assertEqual(str(cm.exception), "can't remove cube file, used as a dependency")
 
     @tag('longrun')