54 percent... wow

This commit is contained in:
2023-12-08 00:44:12 +01:00
parent 9ae71af1aa
commit 0012c52adf
11 changed files with 115 additions and 57 deletions

38
tests/test_file_handle.py Normal file
View File

@@ -0,0 +1,38 @@
import unittest
import shutil
import os
from unittest.mock import Mock
from src.file_handler import sort_pictures
from src.scan_folder import recursive_scan_folder
from src.meta_data_handler import get_meta_data
TEST_IMAGES = "tests/test_files"
TEST_FOLDER = ".test_folder"
def delete_test_folder():
shutil.rmtree(TEST_FOLDER, ignore_errors=True)
def copy_test_images():
delete_test_folder()
os.makedirs(os.path.join(TEST_FOLDER, 'Temp'))
os.makedirs(os.path.join(TEST_FOLDER, 'Images'))
shutil.copy(src=os.path.join(TEST_IMAGES, 'test_image_001.JPG'), dst=os.path.join(TEST_FOLDER, 'Temp'))
shutil.copy(src=os.path.join(TEST_IMAGES, 'test_image_002.JPG'), dst=os.path.join(TEST_FOLDER, 'Temp'))
class TestFileHandler(unittest.TestCase):
def test_file_handler(self):
copy_test_images()
files = recursive_scan_folder(TEST_FOLDER)
exif_data = get_meta_data(files)
sort_pictures(images=exif_data, logger=Mock(), dst=os.path.join(TEST_FOLDER, 'Images'))
sorted_pictures = recursive_scan_folder(TEST_FOLDER)
delete_test_folder()
assert len(sorted_pictures) == 2
assert sorted_pictures == ['.test_folder/Images/SONY/2023/10/25/test_image_002.JPG',
'.test_folder/Images/SONY/2023/10/28/test_image_001.JPG']