From 1f5111cbeab258ae112a5c71e93989a8414b9730 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 13 Jun 2021 19:56:26 +0800 Subject: [PATCH] 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 (cherry picked from commit 9b6be59d6fa6ff7f6c5d773b6774728cf828b768) --- src/test/pybind/test_ceph_argparse.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/pybind/test_ceph_argparse.py b/src/test/pybind/test_ceph_argparse.py index d763b9db55ee..70b7860f0261 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') -- 2.47.3