54 percent... wow
This commit is contained in:
@@ -10,6 +10,6 @@ class TestExifData(unittest.TestCase):
|
||||
month=12,
|
||||
day=12,
|
||||
year=2023,
|
||||
time=1278897213)
|
||||
time="10:10:10")
|
||||
|
||||
assert exif_data.make == "CAMERA"
|
||||
|
||||
38
tests/test_file_handle.py
Normal file
38
tests/test_file_handle.py
Normal 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']
|
||||
BIN
tests/test_files/test_image_001.JPG
Normal file
BIN
tests/test_files/test_image_001.JPG
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 121 B |
BIN
tests/test_files/test_image_002.JPG
Normal file
BIN
tests/test_files/test_image_002.JPG
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 129 B |
@@ -1,6 +1,23 @@
|
||||
import unittest
|
||||
from src.meta_data_handler import MetadataHandler
|
||||
import os
|
||||
|
||||
from src.meta_data_handler import get_meta_data
|
||||
from src.meta_data_handler import get_image_meta_data
|
||||
from src.meta_data_handler import filter_data
|
||||
from src.meta_data_handler import filter_date_and_make
|
||||
from src.meta_data_handler import is_file_video
|
||||
from src.scan_folder import recursive_scan_folder
|
||||
|
||||
TEST_IMAGES = "tests/test_files"
|
||||
|
||||
|
||||
class TestMetadataHandler(unittest.TestCase):
|
||||
pass
|
||||
def test_get_image_meta_data(self):
|
||||
image_exif_data = get_image_meta_data(image_path=f"{TEST_IMAGES}/test_image_001.JPG")
|
||||
assert image_exif_data.name == "test_image_001.JPG"
|
||||
|
||||
def test_get_meta_data(self):
|
||||
images = recursive_scan_folder(TEST_IMAGES)
|
||||
print(images)
|
||||
exif_data = get_meta_data(images)
|
||||
assert len(exif_data) == len(images)
|
||||
|
||||
Reference in New Issue
Block a user