From: Kefu Chai Date: Sun, 13 Jun 2021 11:56:26 +0000 (+0800) Subject: test/pybind/test_ceph_argparse: add a test where args contains comma X-Git-Tag: v17.1.0~1645^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9b6be59d6fa6ff7f6c5d773b6774728cf828b768;p=ceph.git test/pybind/test_ceph_argparse: add a test where args contains comma to ensure the support for the new syntax of "prefix --name bon,jour" does not break existing behavior of "prefix hello cruel,world" where value2 contains reads "hello,world", and the parsed result should be prefix="prefix" value=["hello", "cruel,world"] instead of something like prefix="prefix" value=["hello", "cruel", "world"] or prefix="prefix" value=["cruel", "world"] the above test only applies to the test where "value" is a CephString. if "value" is a CephChoices, the parsed argument should be prefix="prefix" value=["hello", "cruel", "world"] Signed-off-by: Kefu Chai --- diff --git a/src/test/pybind/test_ceph_argparse.py b/src/test/pybind/test_ceph_argparse.py index d763b9db55ee9..70b7860f02615 100755 --- a/src/test/pybind/test_ceph_argparse.py +++ b/src/test/pybind/test_ceph_argparse.py @@ -267,6 +267,21 @@ class TestAuth(TestArgparse): def test_get_or_create_key(self): self.check_1_or_more_string_args('auth', 'get-or-create-key') + prefix = 'auth get-or-create-key' + entity = 'client.test' + caps = ['mon', + 'allow r', + 'osd', + 'allow rw pool=nfs-ganesha namespace=test, allow rw tag cephfs data=user_test_fs', + 'mds', + 'allow rw path=/'] + cmd = prefix.split() + [entity] + caps + assert_equal( + { + 'prefix': prefix, + 'entity': entity, + 'caps': caps + }, validate_command(sigdict, cmd)) def test_get_or_create(self): self.check_1_or_more_string_args('auth', 'get-or-create') @@ -496,6 +511,12 @@ class TestOSD(TestArgparse): def test_osd_tree(self): self.check_0_or_1_natural_arg('osd', 'tree') + cmd = 'osd tree down,out' + assert_equal( + { + 'prefix': 'osd tree', + 'states': ['down', 'out'] + }, validate_command(sigdict, cmd.split())) def test_osd_ls(self): self.check_0_or_1_natural_arg('osd', 'ls')