From 30851ce8a6bf60cba48de372e7c923167cc17d8a Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Sun, 2 Oct 2022 21:18:13 +1100 Subject: Add gen_desc_data.py Add unit test, update README --- backend/tests/test_gen_imgs.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'backend/tests/test_gen_imgs.py') diff --git a/backend/tests/test_gen_imgs.py b/backend/tests/test_gen_imgs.py index 2541c1d..f8bfeb6 100644 --- a/backend/tests/test_gen_imgs.py +++ b/backend/tests/test_gen_imgs.py @@ -11,8 +11,7 @@ class TestGenImgs(unittest.TestCase): @patch('hist_data.gen_imgs.convertImage', autospec=True) def test_gen(self, convertImageMock): with tempfile.TemporaryDirectory() as tempDir: - convertImageMock.side_effect = \ - lambda imgPath, outPath: shutil.copy(imgPath, outPath) + convertImageMock.side_effect = lambda imgPath, outPath: shutil.copy(imgPath, outPath) # Create temp images imgDir = os.path.join(tempDir, 'enwiki_imgs') os.mkdir(imgDir) @@ -63,7 +62,7 @@ class TestGenImgs(unittest.TestCase): '200.jpg', }) self.assertEqual( - readTestDbTable(dbFile, 'SELECT id, img_id from event_imgs'), + readTestDbTable(dbFile, 'SELECT id, img_id FROM event_imgs'), { (10, 100), (20, 200), @@ -71,7 +70,7 @@ class TestGenImgs(unittest.TestCase): } ) self.assertEqual( - readTestDbTable(dbFile, 'SELECT id, url, license, artist, credit from images'), + readTestDbTable(dbFile, 'SELECT id, url, license, artist, credit FROM images'), { (100, 'https://en.wikipedia.org/wiki/File:one.jpg', 'CC BY-SA 3.0', 'author1', 'credits1'), (200, 'https://en.wikipedia.org/wiki/File:two.jpeg', 'cc-by', 'author2', 'credits2'), -- cgit v1.2.3