From: John Mulligan Date: Fri, 28 Jan 2022 16:21:57 +0000 (-0500) Subject: mgr/nfs: add unit test for normalize_path X-Git-Tag: v16.2.8~67^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b295b7967d15016ed4bd528bfe727a6941d362fe;p=ceph.git mgr/nfs: add unit test for normalize_path Signed-off-by: John Mulligan (cherry picked from commit ffa95fbc796aa5c00eaa32138291c0ef2a48949a) --- diff --git a/src/pybind/mgr/nfs/tests/test_nfs.py b/src/pybind/mgr/nfs/tests/test_nfs.py index 4688679db483..c31e5b889683 100644 --- a/src/pybind/mgr/nfs/tests/test_nfs.py +++ b/src/pybind/mgr/nfs/tests/test_nfs.py @@ -12,7 +12,7 @@ from rados import ObjectNotFound from ceph.deployment.service_spec import NFSServiceSpec from nfs import Module -from nfs.export import ExportMgr +from nfs.export import ExportMgr, normalize_path from nfs.export_utils import GaneshaConfParser, Export, RawBlock from nfs.cluster import NFSCluster from orchestrator import ServiceDescription, DaemonDescription, OrchResult @@ -1018,3 +1018,19 @@ NFS_CORE_PARAM { def test_cluster_config(self): self._do_mock_test(self._do_test_cluster_config) + + +@pytest.mark.parametrize( + "path,expected", + [ + ("/foo/bar/baz", "/foo/bar/baz"), + ("/foo/bar/baz/", "/foo/bar/baz"), + ("/foo/bar/baz ", "/foo/bar/baz"), + ("/foo/./bar/baz", "/foo/bar/baz"), + ("/foo/bar/baz/..", "/foo/bar"), + ("//foo/bar/baz", "/foo/bar/baz"), + ("", ""), + ] +) +def test_normalize_path(path, expected): + assert normalize_path(path) == expected