1
0
mirror of https://github.com/sashacmc/photo-importer.git synced 2025-10-06 21:57:04 +02:00
Files
photo-importer/photo_importer/importer_test.py

64 lines
1.8 KiB
Python
Raw Permalink Normal View History

2022-11-29 21:36:39 +01:00
#!/usr/bin/python3
import os
import unittest
import tempfile
2024-07-08 23:40:14 +02:00
from photo_importer import config
from photo_importer import importer
2022-11-29 21:36:39 +01:00
class TestImporter(unittest.TestCase):
def test_importer(self):
with tempfile.TemporaryDirectory() as tmpdirname:
cfg = config.Config()
cfg.set('main', 'move_mode', '0')
imp = importer.Importer(
cfg,
os.path.join(os.path.dirname(__file__), 'test_data'),
tmpdirname,
False,
)
imp.start()
imp.join()
self.assertEqual(
imp.status(),
{
'stage': 'done',
'total': 2,
'move': {
'total': 2,
'moved': 0,
'copied': 2,
'removed': 0,
'skipped': 0,
'processed': 2,
'errors': 0,
},
'rotate': {
'total': 2,
'processed': 2,
'good': 2,
'errors': 0,
},
},
)
files = []
2024-07-08 21:58:48 +02:00
for path, _, fs in os.walk(tmpdirname):
2022-11-29 21:36:39 +01:00
for f in fs:
print(os.path.join(path, f))
files.append(os.path.join(path, f))
files.sort()
self.assertEqual(len(files), 2)
self.assertEqual(
files[0],
2024-07-08 21:58:48 +02:00
os.path.join(tmpdirname, 'Foto/2021/2021-12-19/2021-12-19_13-11-36.jpeg'),
2022-11-29 21:36:39 +01:00
)
self.assertEqual(
files[1],
2024-07-08 21:58:48 +02:00
os.path.join(tmpdirname, 'Foto/2022/2022-11-21/2022-11-21_00-42-07.jpg'),
2022-11-29 21:36:39 +01:00
)