Files
sigal/tests/test_settings.py

60 lines
1.7 KiB
Python
Raw Normal View History

# -*- coding:utf-8 -*-
import os
2014-03-29 23:45:06 +01:00
from sigal.settings import read_settings, get_thumb
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
2012-10-29 23:12:54 +01:00
def test_read_settings(settings):
"""Test that the settings are correctly read."""
assert settings['img_size'] == (640, 480)
assert settings['thumb_size'] == (200, 150)
assert settings['thumb_suffix'] == '.tn'
assert settings['source'] == os.path.join(CURRENT_DIR, 'sample',
'pictures')
2013-05-14 00:38:03 +02:00
def test_get_thumb(settings):
"""Test the get_thumb function."""
tests = [('example.jpg', 'thumbnails/example.tn.jpg'),
('test/example.jpg', 'test/thumbnails/example.tn.jpg'),
('test/t/example.jpg', 'test/t/thumbnails/example.tn.jpg')]
for src, ref in tests:
assert get_thumb(settings, src) == ref
2013-08-18 23:13:34 +02:00
tests = [('example.webm', 'thumbnails/example.tn.jpg'),
('test/example.mp4', 'test/thumbnails/example.tn.jpg'),
('test/t/example.avi', 'test/t/thumbnails/example.tn.jpg')]
for src, ref in tests:
assert get_thumb(settings, src) == ref
def test_img_sizes(tmpdir):
"""Test that image size is swaped if needed."""
conf = tmpdir.join('sigal.conf.py')
conf.write("""# -*- coding: utf-8 -*-
2013-02-19 00:55:39 +01:00
thumb_size = (150, 200)
""")
2013-02-19 22:59:50 +01:00
settings = read_settings(str(conf))
assert settings['thumb_size'] == (200, 150)
def test_theme_path(tmpdir):
"""Test that image size is swaped if needed."""
tmpdir.join('theme').mkdir()
tmpdir.join('theme').join('templates').mkdir()
conf = tmpdir.join('sigal.conf.py')
conf.write("""# -*- coding: utf-8 -*-
theme = 'theme'
""")
settings = read_settings(str(conf))
assert settings['theme'] == tmpdir.join('theme')