Skip to content

Commit

Permalink
removing generator, adding test comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dgraeber committed Dec 6, 2024
1 parent b3b6d27 commit 2097e83
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 2 additions & 4 deletions seedfarmer/mgmt/archive_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ def _extract_archive(archive_name: str, extracted_dir_path: str) -> str:
embedded_dir = top_level_dirs.pop()
else:
embedded_dir = ""
members_to_extract = [m for m in all_members]
tar_file.extractall(extracted_dir_path, members=members_to_extract)
tar_file.extractall(extracted_dir_path, members=all_members)
else:
with ZipFile(archive_name, "r") as zip_file:
all_files = zip_file.namelist()
Expand All @@ -96,8 +95,7 @@ def _extract_archive(archive_name: str, extracted_dir_path: str) -> str:
embedded_dir = top_level_dirs.pop()
else:
embedded_dir = ""
files_to_extract = [f for f in all_files]
for file in files_to_extract:
for file in all_files:
zip_file.extract(file, path=extracted_dir_path)
return embedded_dir

Expand Down
10 changes: 10 additions & 0 deletions test/unit-test/test_mgmt_archive_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def parent_dir_prepare():
shutil.rmtree(parent_dir)


# This represents a proper archive with the project (test-project) at the root
# are are ignoring the hidden file at the root, and the other files
# under test-project are not used
example_archive_files = [
("test-project/modules/test-module/modulestack.yaml", io.BytesIO(b"111")),
("test-project/modules/test-module/pyproject.toml", io.BytesIO(b"222")),
Expand All @@ -87,13 +90,18 @@ def parent_dir_prepare():
(".DS_Store_local", io.BytesIO(b"555")),
]

# This represents a proper archive with the project (test-project) at the root
# are are ignoring the hidden file at the root, and the other file is not used
example_archive_files_single_module = [
("test-project/modules/test-module/deployspec.yaml", io.BytesIO(b"666")),
("test-project/modules/test-module/something.yaml", io.BytesIO(b"777")),
(".DS_Store", io.BytesIO(b"888")),
("README.md", io.BytesIO(b"999")),
]

# This represents a an archive without a nested dir (project)
# This is not recommended as it is not a proper SF project,
# but can support due to customer ask
example_archive_files_no_nesting = [
("deployspec.yaml", io.BytesIO(b"1010")),
("app.py", io.BytesIO(b"1011")),
Expand All @@ -102,6 +110,8 @@ def parent_dir_prepare():
("README.md", io.BytesIO(b"1014")),
]

# This is a bad package as there are two dirs at the
# root level...that is not allowed
example_archive_files_bad_structure = [
("test-project/deployspec.yaml", io.BytesIO(b"1200")),
("test-project_additional/deployspec.yaml", io.BytesIO(b"1201")),
Expand Down

0 comments on commit 2097e83

Please sign in to comment.