Refactor test fixtures.

This commit is contained in:
Simon Conseil
2014-03-29 22:56:47 +01:00
parent 012758a77e
commit 45f6bcd2a0
3 changed files with 16 additions and 16 deletions

14
tests/conftest.py Normal file
View File

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

View File

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

View File

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