Skip to content

Commit

Permalink
fix one test
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle committed Dec 19, 2024
1 parent bc619a5 commit c417afc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 8 additions & 5 deletions src/antares_web_installer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from antares_web_installer.shortcuts import create_shortcut, get_desktop

# List of files and directories to exclude during installation
EXCLUDED_FILES = {
EXCLUDED_ROOT_RESOURCES = {
Path("config.yaml"),
Path("archives"),
Path("internal_studies"),
Expand Down Expand Up @@ -188,13 +188,16 @@ def copy_files(self):
write or if self.target_dir already exists.
"""
src_dir_content = list(self.source_dir.iterdir())
src_dir_content_length = len(src_dir_content)
dirs_to_copy = []
for root_dir in src_dir_content:
if root_dir.relative_to(self.source_dir) not in EXCLUDED_ROOT_RESOURCES:
dirs_to_copy.append(root_dir)
src_dir_content_length = len(dirs_to_copy)

initial_value = self.progress

for index, elt_path in enumerate(src_dir_content):
relative_elt_path = elt_path.relative_to(self.source_dir)
if relative_elt_path not in EXCLUDED_FILES and not elt_path.name.lower().startswith("antareswebinstaller"):
for index, elt_path in enumerate(dirs_to_copy):
if not elt_path.name.lower().startswith("antareswebinstaller"):
logger.info(f"Copying '{elt_path}'")
try:
if elt_path.is_file():
Expand Down
6 changes: 3 additions & 3 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest

from antares_web_installer.app import App, EXCLUDED_FILES
from antares_web_installer.app import App, EXCLUDED_ROOT_RESOURCES


class TestApp:
Expand Down Expand Up @@ -62,8 +62,8 @@ def test_copy_files__nominal_case(self, datadir: Path) -> None:
content = file.read_bytes()
old_checksum = old_checksum_by_name[relative_path]
new_checksum = hashlib.md5(content).hexdigest()
root_name = relative_path.parts[0]
if root_name in EXCLUDED_FILES:
root_name = Path(relative_path.parts[0])
if root_name in EXCLUDED_ROOT_RESOURCES:
assert old_checksum == new_checksum, f"File {file} must not have been modified"
else:
assert old_checksum != new_checksum, f"File {file} must have been updated"
Expand Down

0 comments on commit c417afc

Please sign in to comment.