From 8781fdb2b8c530a6c1531ae9e82221eb062e34fb Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Sun, 29 Jan 2023 11:30:47 +1100 Subject: Adjust backend coding style Add line spacing, section comments, and import consistency --- backend/tests/eol/test_download_imgs.py | 8 +++++++- backend/tests/eol/test_gen_images_list_db.py | 5 ++++- backend/tests/eol/test_review_imgs.py | 7 ++++++- 3 files changed, 17 insertions(+), 3 deletions(-) (limited to 'backend/tests/eol') diff --git a/backend/tests/eol/test_download_imgs.py b/backend/tests/eol/test_download_imgs.py index 975d1c7..4872ca3 100644 --- a/backend/tests/eol/test_download_imgs.py +++ b/backend/tests/eol/test_download_imgs.py @@ -1,6 +1,7 @@ import unittest from unittest.mock import Mock, patch -import tempfile, os +import tempfile +import os from tests.common import readTestFile, createTestDbTable from tol_data.eol.download_imgs import getEolIdsFromDb, downloadImgs @@ -19,8 +20,10 @@ class TestGetEolIdsFromDb(unittest.TestCase): ('a second', 2), } ) + # Run eolIds = getEolIdsFromDb(dbFile) + # Check self.assertEqual(eolIds, {1, 2}) @@ -30,6 +33,7 @@ class TestDownloadImgs(unittest.TestCase): requestsGetMock.side_effect = lambda url: Mock(content=('img:' + url).encode()) with tempfile.TemporaryDirectory() as tempDir: eolIds = {1, 2, 4} + # Create temp images-list db imagesListDb = os.path.join(tempDir, 'images_list.db') createTestDbTable( @@ -48,10 +52,12 @@ class TestDownloadImgs(unittest.TestCase): (30, 3, '', 'https://content.eol.org/3.png', 'cc-by', 'owner3'), } ) + # Create temp output dir with tempfile.TemporaryDirectory() as outDir: # Run downloadImgs(eolIds, imagesListDb, outDir) + # Check expectedImgs1 = { '1 10.jpg': 'img:https://content.eol.org/1.jpg', diff --git a/backend/tests/eol/test_gen_images_list_db.py b/backend/tests/eol/test_gen_images_list_db.py index ca9b495..c1c81f3 100644 --- a/backend/tests/eol/test_gen_images_list_db.py +++ b/backend/tests/eol/test_gen_images_list_db.py @@ -1,5 +1,6 @@ import unittest -import tempfile, os +import tempfile +import os from tests.common import createTestFile, readTestDbTable from tol_data.eol.gen_images_list_db import genData @@ -17,9 +18,11 @@ class TestGenData(unittest.TestCase): createTestFile(os.path.join(tempDir, 'imgs-2.csv'), ( '3,30,https://example.com/3/,https://content.eol.org/3.png,public,owner3\n' )) + # Run dbFile = os.path.join(tempDir, 'imagesList.db') genData(imageListsGlob, dbFile) + # Check self.assertEqual( readTestDbTable( diff --git a/backend/tests/eol/test_review_imgs.py b/backend/tests/eol/test_review_imgs.py index 49c09bb..21d4756 100644 --- a/backend/tests/eol/test_review_imgs.py +++ b/backend/tests/eol/test_review_imgs.py @@ -1,5 +1,7 @@ import unittest -import tempfile, os, shutil +import tempfile +import os +import shutil from tests.common import createTestDbTable from tol_data.eol.review_imgs import reviewImgs @@ -19,6 +21,7 @@ class TestReviewImgs(unittest.TestCase): shutil.copy(AVOID_IMG, os.path.join(imgDir, '2 22.jpg')) shutil.copy(AVOID_IMG, os.path.join(imgDir, '3 30.png')) shutil.copy(AVOID_IMG, os.path.join(imgDir, '3 31.jpg')) + # Create temp extra-info db extraInfoDb = os.path.join(tempDir, 'data.db') createTestDbTable( @@ -39,8 +42,10 @@ class TestReviewImgs(unittest.TestCase): ('two','II',1,'eol'), } ) + # Run outDir = os.path.join(tempDir, 'imgs') reviewImgs(imgDir, outDir, extraInfoDb) + # Check self.assertEqual(set(os.listdir(outDir)), {'1 10.jpg', '2 20.jpeg'}) -- cgit v1.2.3