fix tests for gallery

This commit is contained in:
Simon
2012-11-07 01:01:12 +01:00
parent 9e0918e0af
commit 1a85719e5c
2 changed files with 35 additions and 31 deletions

35
tests/test_gallery.py Normal file
View File

@@ -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')

View File

@@ -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)