Skip to content

Commit

Permalink
Add new changes to make private method public
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Zhu <[email protected]>
  • Loading branch information
peterzhuamazon committed Feb 28, 2022
1 parent 86920b3 commit 612c77a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/assemble_workflow/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
'''
Expand All @@ -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.
Expand All @@ -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

Expand Down
10 changes: 5 additions & 5 deletions tests/tests_assemble_workflow/test_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -46,21 +46,21 @@ 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"
)

@patch("os.path.dirname", return_value="temp_path")
@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"
)

0 comments on commit 612c77a

Please sign in to comment.