Skip to content

Commit

Permalink
tests:utils - add explicit tests for file_checksum, is_binary, and rm…
Browse files Browse the repository at this point in the history
…_tree
  • Loading branch information
MatteoCampinoti94 committed Oct 31, 2023
1 parent 9d0425e commit 0d9b628
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
from pathlib import Path
from re import match

from acacore.utils.functions import file_checksum
from acacore.utils.functions import is_binary
from acacore.utils.functions import or_none
from acacore.utils.functions import rm_tree
from acacore.utils.io import size_fmt
from acacore.utils.log import setup_logger


def test_functions():
def test_functions(test_files: Path, test_files_data: dict[str, dict], temp_folder: Path):
# or_none
func = or_none(lambda _: 5)
assert func(1) == 5
assert func(None) is None

# file_checksum
for filename, filedata in test_files_data.items():
assert file_checksum(test_files / filename) == filedata["checksum"]

# is_binary
for filename, filedata in test_files_data.items():
assert is_binary(test_files / filename) == filedata["binary"]

# rm_tree
test_folder = temp_folder.joinpath("1")
test_folder.joinpath("2", "3").mkdir(parents=True, exist_ok=True)
rm_tree(test_folder)
assert not test_folder.is_dir()
assert temp_folder.is_dir()


def test_io():
# size_fmt
Expand Down

0 comments on commit 0d9b628

Please sign in to comment.