aboutsummaryrefslogtreecommitdiff
path: root/backend/tests/test_gen_imgs.py
diff options
context:
space:
mode:
authorTerry Truong <terry06890@gmail.com>2023-01-21 12:21:03 +1100
committerTerry Truong <terry06890@gmail.com>2023-01-21 12:32:01 +1100
commit0a9b2c2e5eca8a04e37fbdd423379882863237c2 (patch)
tree1812bdb6bb13e4f76fdd7ef04075b291f775c213 /backend/tests/test_gen_imgs.py
parent8321e2f92dbc073b8f1de87895d6620a2021b22e (diff)
Adjust backend coding style
Increase line spacing, add section comments, etc
Diffstat (limited to 'backend/tests/test_gen_imgs.py')
-rw-r--r--backend/tests/test_gen_imgs.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/backend/tests/test_gen_imgs.py b/backend/tests/test_gen_imgs.py
index ea4bd70..893be5c 100644
--- a/backend/tests/test_gen_imgs.py
+++ b/backend/tests/test_gen_imgs.py
@@ -1,6 +1,8 @@
import unittest
from unittest.mock import patch
-import tempfile, os, shutil
+import tempfile
+import os
+import shutil
from tests.common import createTestDbTable, readTestDbTable
from hist_data.gen_imgs import genImgs
@@ -12,12 +14,14 @@ class TestGenImgs(unittest.TestCase):
def test_gen(self, convertImageMock):
with tempfile.TemporaryDirectory() as tempDir:
convertImageMock.side_effect = lambda imgPath, outPath: shutil.copy(imgPath, outPath)
+
# Create temp images
imgDir = os.path.join(tempDir, 'enwiki_imgs')
os.mkdir(imgDir)
shutil.copy(TEST_IMG, os.path.join(imgDir, '100.jpg'))
shutil.copy(TEST_IMG, os.path.join(imgDir, '200.jpeg'))
shutil.copy(TEST_IMG, os.path.join(imgDir, '400.png'))
+
# Create temp image db
imgDb = os.path.join(tempDir, 'img_data.db')
createTestDbTable(
@@ -40,6 +44,7 @@ class TestGenImgs(unittest.TestCase):
(200, 'two.jpeg', 'cc-by', 'author2', 'credits2', '', 'https://upload.wikimedia.org/two.jpeg'),
}
)
+
# Create temp history db
dbFile = os.path.join(tempDir, 'data.db')
createTestDbTable(
@@ -53,9 +58,11 @@ class TestGenImgs(unittest.TestCase):
(30, 'third', 1, 20, 30, 40, 1, 'event'),
}
)
+
# Run
outDir = os.path.join(tempDir, 'imgs')
genImgs(imgDir, imgDb, outDir, dbFile)
+
# Check
self.assertEqual(set(os.listdir(outDir)), {
'100.jpg',