From 612c77a63821280853a72892eece109e11d9a6cb Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Mon, 28 Feb 2022 21:53:40 +0000 Subject: [PATCH] Add new changes to make private method public Signed-off-by: Peter Zhu --- src/assemble_workflow/dist.py | 8 ++++---- tests/tests_assemble_workflow/test_dist.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/assemble_workflow/dist.py b/src/assemble_workflow/dist.py index faa1182a8f..4f54107fbe 100644 --- a/src/assemble_workflow/dist.py +++ b/src/assemble_workflow/dist.py @@ -29,7 +29,7 @@ def __extract__(self, dest: str) -> None: def __build__(self, name: str, dest: str) -> None: pass - def __find_min_archive_path(self, dest: str) -> str: + def find_min_archive_path(self, dest: str) -> str: ''' Return the single folder at the top level of the tar. ''' @@ -41,7 +41,7 @@ def __find_min_archive_path(self, dest: str) -> str: raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), os.path.join(dest, "*")) - def __rename_archive_path(self, path: str) -> str: + def rename_archive_path(self, path: str) -> str: ''' Rename the single folder at the top level of the tar that contains the min distribution to match current version. For example, when OpenSearch 1.1.1 is built using the 1.1.0 artifact, we rename opensearch-1.1.0 to opensearch-1.1.1. @@ -58,8 +58,8 @@ def __rename_archive_path(self, path: str) -> str: def extract(self, dest: str) -> str: self.__extract__(dest) - self.archive_path = self.__rename_archive_path( - self.__find_min_archive_path(dest) + self.archive_path = self.rename_archive_path( + self.find_min_archive_path(dest) ) return self.archive_path diff --git a/tests/tests_assemble_workflow/test_dist.py b/tests/tests_assemble_workflow/test_dist.py index 64dc012139..e1b3b9d175 100644 --- a/tests/tests_assemble_workflow/test_dist.py +++ b/tests/tests_assemble_workflow/test_dist.py @@ -27,8 +27,8 @@ def test_dist_variables(self) -> None: self.assertEqual(os.path.exists(self.distTar.path), True) self.assertEqual(self.distTar.min_path, "opensearch-1.3.0") - @patch("assemble_workflow.dist.Dist._Dist__find_min_archive_path", return_value="opensearch-1.3.0") - @patch("assemble_workflow.dist.Dist._Dist__rename_archive_path", return_value="test_path") + @patch("assemble_workflow.dist.Dist.find_min_archive_path", return_value="opensearch-1.3.0") + @patch("assemble_workflow.dist.Dist.rename_archive_path", return_value="test_path") @patch("assemble_workflow.dist.DistTar.__extract__") def test_dist_extract(self, dist_find_min_path: Mock, dist_rename_path: Mock, distTar_extract: Mock) -> None: archive_path = self.distTar.extract("test_dest") @@ -46,14 +46,14 @@ def test_dist_build(self, distTar_build: Mock, shutil_copyfile: Mock) -> None: def test_find_min_archive_path(self) -> None: self.assertEqual( - self.distTar._Dist__find_min_archive_path(self.artifacts_path), + self.distTar.find_min_archive_path(self.artifacts_path), self.artifacts_path + "opensearch-1.3.0" ) @patch("os.path.basename", return_value="opensearch-1.3.0") def test_rename_archive_path_norename(self, os_path_basename: Mock) -> None: self.assertEqual( - self.distTar._Dist__rename_archive_path("temp_path/opensearch-1.3.0"), + self.distTar.rename_archive_path("temp_path/opensearch-1.3.0"), "temp_path/opensearch-1.3.0" ) @@ -61,6 +61,6 @@ def test_rename_archive_path_norename(self, os_path_basename: Mock) -> None: @patch("os.rename") def test_rename_archive_path_rename(self, os_path_dirname: Mock, os_rename: Mock) -> None: self.assertEqual( - self.distTar._Dist__rename_archive_path("temp_path/opensearch-x.y.z"), + self.distTar.rename_archive_path("temp_path/opensearch-x.y.z"), "temp_path/opensearch-1.3.0" )