diff --git a/tests/test_gallery.py b/tests/test_gallery.py new file mode 100644 index 0000000..d17c7b5 --- /dev/null +++ b/tests/test_gallery.py @@ -0,0 +1,35 @@ +#! /usr/bin/env python2 +# -*- coding:utf-8 -*- + +import os +import unittest + +from sigal.gallery import Gallery +from sigal.settings import read_settings + +CURRENT_DIR = os.path.dirname(__file__) + + +class TestGallery(unittest.TestCase): + "Test the Gallery class." + + def setUp(self): + """Read the sample config file.""" + + default_conf = os.path.join(CURRENT_DIR, 'sample', 'sigal.conf') + settings = read_settings(default_conf) + self.gal = Gallery(settings, os.path.join(CURRENT_DIR, 'sample'), + os.path.join(CURRENT_DIR, 'output')) + + def test_filelist(self): + self.gal.build_paths() + paths = self.gal.paths + + self.assertItemsEqual(paths.keys(), ['.', 'dir1', 'dir2']) + + self.assertListEqual(paths['.']['img'], []) + self.assertItemsEqual(paths['.']['subdir'], ['dir1', 'dir2']) + + self.assertItemsEqual(paths['dir1']['img'], ['test1.jpg', 'test2.jpg']) + self.assertEqual(paths['dir1']['representative'], u'test1.jpg') + self.assertEqual(paths['dir1']['title'], u'An example gallery') diff --git a/tests/test_image.py b/tests/test_image.py deleted file mode 100644 index 6786c76..0000000 --- a/tests/test_image.py +++ /dev/null @@ -1,31 +0,0 @@ -#! /usr/bin/env python2 -# -*- coding:utf-8 -*- - -import os -import unittest - -from sigal.gallery import Gallery -from sigal.settings import read_settings - - -class TestGallery(unittest.TestCase): - "Test the Gallery class." - - def setUp(self): - "Read the sample config file" - self.path = os.path.dirname(__file__) - default_conf = os.path.join(self.path, 'sample', 'sigal.conf') - settings = read_settings(default_conf) - self.gallery = Gallery(settings, os.path.join(self.path, 'sample'), - os.path.join(self.path, 'output')) - - def test_filelist(self): - file_generator = self.gallery.filelist() - dirpath, dirnames, imglist = file_generator.next() - self.assertEqual(dirpath, os.path.join(self.path, 'sample')) - self.assertListEqual(imglist, []) - - reflist = [os.path.join(self.path, 'sample', 'dir2', f) - for f in ['test1.jpg', 'test2.jpg']] - dirpath, dirnames, imglist = file_generator.next() - self.assertItemsEqual(imglist, reflist)