Skip to content

Commit

Permalink
Merge pull request #31 from WD-Scott/updates_initial
Browse files Browse the repository at this point in the history
added workflow job to run test suite
  • Loading branch information
WD-Scott authored Aug 14, 2024
2 parents c3c0c01 + 42811a9 commit ceedb66
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ drop_temp_downloads:

# Job to run tests
.PHONY: test
test: drop_temp_downloads
pytest tests -vvx
test:
pytest tests -vvx
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pyinstaller
PySimpleGUI
PySimpleGUI
pytest
Binary file modified tests/.DS_Store
Binary file not shown.
9 changes: 5 additions & 4 deletions tests/test_cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import os
import shutil
import pytest
from pkg_cleaner import make_unique, config, scan_create, scan_new, MoverHandler
from pkg_cleaner import make_unique, config, scan_create, MoverHandler

dst = '/Downloads/'
FLDRS = ["Images", "Videos", "Audio", "Documents", "Coding"]
Expand Down Expand Up @@ -56,7 +56,7 @@ def mock_downloads_dir(tmpdir_factory):
os.makedirs(os.path.join(mock_dir, subdir))

for file_name in test_files:
with open(os.path.join(mock_dir, file_name), 'w') as f:
with open(os.path.join(mock_dir, file_name), 'w', encoding='utf-8') as f:
f.write("test")

yield mock_dir
Expand Down Expand Up @@ -113,6 +113,7 @@ def test_config():
dl = '/Downloads'
assert cfg[-10:] == dl, f"Source dir should end with {dl} but got {cfg}"

@pytest.mark.skipif(os.environ.get('CI') == 'true', reason="Skipping GUI tests in CI environment")
@pytest.mark.parametrize("new_name, original", test_cases, ids=test_ids)
def test_make_unique(new_name, original, counter=2):
'''
Expand All @@ -124,6 +125,7 @@ def test_make_unique(new_name, original, counter=2):
'''
assert make_unique(dst, original, counter=2) == new_name

@pytest.mark.skipif(os.environ.get('CI') == 'true', reason="Skipping GUI tests in CI environment")
def test_process(mock_downloads_dir):
'''
Tests the `MoverHandler` class' `process` method.
Expand All @@ -134,7 +136,7 @@ def test_process(mock_downloads_dir):
'''
config['source_dir'] = str(mock_downloads_dir)
config['directories'] = {folder: os.path.join(str(mock_downloads_dir), folder)\
for folder in config['directories'].keys()}
for folder in config['directories']}

handler = MoverHandler()
handler.process()
Expand All @@ -146,4 +148,3 @@ def test_process(mock_downloads_dir):
for file in files:
assert any(file.endswith(ext) for ext in config['extensions'][category]),\
f"File {file} in {directory} does not have the correct extension"

0 comments on commit ceedb66

Please sign in to comment.