-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from WD-Scott/updates_initial
started creating test scripts and added makefile job to run them
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
''' | ||
test_cleaner.py | ||
=============== | ||
Author: | ||
------- | ||
Wyatt D. Scott ([email protected]) | ||
Last Updated: | ||
------------- | ||
09 August 2024 | ||
''' | ||
import os | ||
import logging | ||
from os.path import exists, join, splitext | ||
from shutil import move | ||
import pytest | ||
from cleaner import make_unique, config | ||
|
||
dst = '/Downloads/' | ||
|
||
test_cases = [ | ||
("tester(2).png", 'tester.png'), | ||
("tester(2).py", 'tester.py'), | ||
("tester(2).pdf", 'tester.pdf'), | ||
("tester(2).mp4", 'tester.mp4'), | ||
("tester(2).mp3", 'tester.mp3') | ||
] | ||
|
||
test_ids = [name for name, _ in test_cases] | ||
|
||
def test_config(): | ||
''' | ||
Tests the config setup in cleaner.py. | ||
GIVEN the config dict | ||
WHEN source dir is initialized | ||
THEN ensure it ends with '/Downloads' | ||
''' | ||
cfg = config.get('source_dir') | ||
dl = '/Downloads' | ||
assert cfg[-10:] == dl, f"Source dir should end with {dl} but got {cfg}" | ||
|
||
|
||
@pytest.mark.parametrize("new_name, original", test_cases, ids=test_ids) | ||
def test_make_unique(new_name, original, counter=2): | ||
''' | ||
Tests the `make_unique` function from cleaner.py. | ||
GIVEN a file name and destination | ||
WHEN checking if a unique file name is generated | ||
THEN ensure the name is unique and formatted correctly | ||
''' | ||
assert make_unique(dst, original, 2) == new_name |