]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/pybind/test_ceph_argparse: check for expected argument
authorKefu Chai <kchai@redhat.com>
Sun, 13 Jun 2021 04:03:11 +0000 (12:03 +0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 30 Jun 2021 19:04:16 +0000 (12:04 -0700)
instead of comparing the validated argument with empty dict, check for
its content for better coverage of testing.

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit cf4570d663d9c0fb656a54adc03fdfe83ead6ed0)

src/test/pybind/test_ceph_argparse.py

index dfdf253b0682fa957a304af306b783475ee1d22b..d763b9db55ee90ff0938cef72e05703254c6c2c5 100755 (executable)
@@ -146,19 +146,26 @@ class TestPG(TestArgparse):
         self.assert_valid_command(['pg', 'getmap'])
 
     def test_dump(self):
-        self.assert_valid_command(['pg', 'dump'])
-        self.assert_valid_command(['pg', 'dump',
-                                   'all',
-                                   'summary',
-                                   'sum',
-                                   'delta',
-                                   'pools',
-                                   'osds',
-                                   'pgs',
-                                   'pgs_brief'])
-        self.assert_valid_command('pg dump --dumpcontents summary,sum'.split())
-        self.assert_valid_command('pg dump summary,sum'.split())
-        assert_equal({}, validate_command(sigdict, ['pg', 'dump', 'invalid']))
+        valid_commands = {
+            'pg dump': {'prefix': 'pg dump'},
+            'pg dump all summary sum delta pools osds pgs pgs_brief':
+            {'prefix': 'pg dump',
+             'dumpcontents':
+             'all summary sum delta pools osds pgs pgs_brief'.split()
+             },
+            'pg dump --dumpcontents summary,sum':
+            {'prefix': 'pg dump',
+             'dumpcontents': 'summary,sum'.split(',')
+             }
+        }
+        for command, expected_result in valid_commands.items():
+            actual_result = validate_command(sigdict, command.split())
+            expected_result['target'] = ('mon-mgr', '')
+            assert_equal(expected_result, actual_result)
+        invalid_commands = ['pg dump invalid']
+        for command in invalid_commands:
+            actual_result = validate_command(sigdict, command.split())
+            assert_equal({}, actual_result)
 
     def test_dump_json(self):
         self.assert_valid_command(['pg', 'dump_json'])