Browse Source

Fix video filename for tests.

The error was not detected is the _build was present. So this commit also
removes the _build before each test.
pull/195/head
Simon Conseil 10 years ago
parent
commit
578636b194
  1. 1
      .travis.yml
  2. 9
      tests/conftest.py
  3. 24
      tests/test_gallery.py

1
.travis.yml

@ -14,6 +14,7 @@ before_install:
- sudo apt-get install -qq ubuntu-restricted-extras
- sudo apt-get install -qq libfreetype6-dev libjpeg8-dev zlib1g-dev ffmpeg
- sudo locale-gen fr_FR.UTF-8
- ffmpeg -version
install:
- pip install -q Pillow==$PILLOW_VERSION
- pip install pytest pytest-cov

9
tests/conftest.py

@ -3,10 +3,19 @@
import os
import PIL
import pytest
import shutil
from sigal.settings import read_settings
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
BUILD_DIR = os.path.join(CURRENT_DIR, 'sample', '_build')
@pytest.fixture(scope='session', autouse=True)
def remove_build():
"""Ensure that build directory does not exists before each test."""
if os.path.exists(BUILD_DIR):
shutil.rmtree(BUILD_DIR)
@pytest.fixture

24
tests/test_gallery.py

@ -66,7 +66,7 @@ REF = {
'thumbnail': ('video/thumbnails/'
'stallman software-freedom-day-low.tn.jpg'),
'subdirs': [],
'medias': ['stallman software-freedom-day-low.webm']
'medias': ['stallman software-freedom-day-low.ogv']
}
}
@ -151,27 +151,19 @@ def test_album(path, album, settings, tmpdir):
assert a.name == album['name']
assert a.subdirs == album['subdirs']
assert a.thumbnail == album['thumbnail']
assert [m.filename for m in a.medias] == album['medias']
if path == 'video':
assert list(a.images) == []
assert [m.filename for m in a.medias] == \
[album['medias'][0].replace('.ogv', '.webm')]
else:
assert list(a.videos) == []
assert [m.filename for m in a.medias] == album['medias']
assert len(a) == len(album['medias'])
finally:
# restore locale back
locale.setlocale(locale.LC_ALL, old_locale)
def test_album_medias(settings):
gal = Gallery(settings, ncpu=1)
album = REF['dir1/test1']
a = Album('dir1/test1', settings, album['subdirs'], album['medias'], gal)
assert list(im.filename for im in a.images) == album['medias']
assert list(a.videos) == []
album = REF['video']
a = Album('video', settings, album['subdirs'], album['medias'], gal)
assert list(im.filename for im in a.videos) == album['medias']
assert list(a.images) == []
def test_albums_sort(settings):
gal = Gallery(settings, ncpu=1)
album = REF['dir1']

Loading…
Cancel
Save