]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
neutron-db-manage: expose alembic 'heads' command
authorIhar Hrachyshka <ihrachys@redhat.com>
Fri, 20 Nov 2015 16:35:10 +0000 (17:35 +0100)
committerIhar Hrachyshka <ihrachys@redhat.com>
Fri, 20 Nov 2015 16:39:11 +0000 (17:39 +0100)
This command shows current heads in all alembic branches. Even without
the command, we *can* get the heads values by looking into *_HEAD files
in tree. Still, those files may be missing; and the command is a tiny
bit more easy to use. Also, it gives access to more details on head
revisions if used with --verbose.

Change-Id: I6e7b7b5cd6f704d5d4bb4d845bf5098d4045924a

neutron/db/migration/cli.py
neutron/tests/unit/db/test_migration.py

index 99bf7e6055895a2238b6a9988a0c20e1b8de8029..9dc22112cf6d863ded157b918885970c8464394c 100644 (file)
@@ -431,7 +431,7 @@ def update_head_file(config):
 
 
 def add_command_parsers(subparsers):
-    for name in ['current', 'history', 'branches']:
+    for name in ['current', 'history', 'branches', 'heads']:
         parser = add_alembic_subparser(subparsers, name)
         parser.set_defaults(func=do_generic_show)
         parser.add_argument('--verbose',
index 578343154624248ce7251d8f969db2110e2b8df3..20f25c7ea0028baf03e395672bc116520d2d044a 100644 (file)
@@ -173,38 +173,28 @@ class TestCli(base.BaseTestCase):
             [{'revision': 'foo', 'sql': True}]
         )
 
-    def test_branches(self):
+    def _validate_cmd(self, cmd):
         self._main_test_helper(
-            ['prog', 'branches'],
-            'branches',
+            ['prog', cmd],
+            cmd,
             [{'verbose': False}])
 
         self._main_test_helper(
-            ['prog', 'branches', '--verbose'],
-            'branches',
+            ['prog', cmd, '--verbose'],
+            cmd,
             [{'verbose': True}])
 
-    def test_current(self):
-        self._main_test_helper(
-            ['prog', 'current'],
-            'current',
-            [{'verbose': False}])
+    def test_branches(self):
+        self._validate_cmd('branches')
 
-        self._main_test_helper(
-            ['prog', 'current', '--verbose'],
-            'current',
-            [{'verbose': True}])
+    def test_current(self):
+        self._validate_cmd('current')
 
     def test_history(self):
-        self._main_test_helper(
-            ['prog', 'history'],
-            'history',
-            [{'verbose': False}])
+        self._validate_cmd('history')
 
-        self._main_test_helper(
-            ['prog', 'history', '--verbose'],
-            'history',
-            [{'verbose': True}])
+    def test_heads(self):
+        self._validate_cmd('heads')
 
     def test_check_migration(self):
         with mock.patch.object(cli, 'validate_head_file') as validate: