Browse Source

Refactor test fixtures.

pull/87/merge
Simon Conseil 12 years ago
parent
commit
45f6bcd2a0
  1. 14
      tests/conftest.py
  2. 11
      tests/test_gallery.py
  3. 7
      tests/test_settings.py

14
tests/conftest.py

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
import os
import pytest
from sigal.settings import read_settings
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
@pytest.fixture(scope='session')
def settings():
"""Read the sample config file."""
return read_settings(os.path.join(CURRENT_DIR, 'sample', 'sigal.conf.py'))

11
tests/test_gallery.py

@ -6,10 +6,8 @@ import pytest
from os.path import join
from sigal.gallery import Album, Media, Image, Video, Gallery
from sigal.settings import read_settings
CURRENT_DIR = os.path.dirname(__file__)
SAMPLE_DIR = os.path.join(CURRENT_DIR, 'sample')
REF = {
'dir1': {
@ -54,19 +52,14 @@ REF = {
'video': {
'title': 'Video',
'name': 'video',
'thumbnail': 'video/thumbnails/stallman software-freedom-day-low.tn.jpg',
'thumbnail': ('video/thumbnails/'
'stallman software-freedom-day-low.tn.jpg'),
'subdirs': [],
'medias': ['stallman software-freedom-day-low.ogv']
}
}
@pytest.fixture(scope='module')
def settings():
"""Read the sample config file."""
return read_settings(os.path.join(SAMPLE_DIR, 'sigal.conf.py'))
def test_media(settings):
m = Media('11.jpg', 'dir1/test1', settings)
path = join('dir1', 'test1')

7
tests/test_settings.py

@ -1,19 +1,12 @@
# -*- coding:utf-8 -*-
import os
import pytest
from sigal.settings import read_settings, get_thumb, get_orig
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
@pytest.fixture(scope='module')
def settings():
"""Read the sample config file."""
return read_settings(os.path.join(CURRENT_DIR, 'sample', 'sigal.conf.py'))
def test_read_settings(settings):
"""Test that the settings are correctly read."""
assert settings['img_size'] == (640, 480)

Loading…
Cancel
Save