Adapt code to work with the latest changes on master.

This commit is contained in:
Simon Conseil
2014-07-17 00:32:42 +02:00
parent b8733c68ec
commit 71afbf5355
10 changed files with 73 additions and 97 deletions

View File

@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import os
from sigal.utils import copy, check_or_create_dir, url_from_path
from sigal import utils
CURRENT_DIR = os.path.dirname(__file__)
SAMPLE_DIR = os.path.join(CURRENT_DIR, 'sample')
@@ -11,28 +11,37 @@ def test_copy(tmpdir):
filename = 'exo20101028-b-full.jpg'
src = os.path.join(SAMPLE_DIR, 'pictures', 'dir2', filename)
dst = str(tmpdir.join(filename))
copy(src, dst)
utils.copy(src, dst)
assert os.path.isfile(dst)
filename = 'm57_the_ring_nebula-587px.jpg'
src = os.path.join(SAMPLE_DIR, 'pictures', 'dir2', filename)
dst = str(tmpdir.join(filename))
copy(src, dst, symlink=True)
utils.copy(src, dst, symlink=True)
assert os.path.islink(dst)
assert os.readlink(dst) == src
filename = 'exo20101028-b-full.jpg'
src = os.path.join(SAMPLE_DIR, 'pictures', 'dir2', filename)
copy(src, dst, symlink=True)
utils.copy(src, dst, symlink=True)
assert os.path.islink(dst)
assert os.readlink(dst) == src
def test_check_or_create_dir(tmpdir):
path = str(tmpdir.join('new_directory'))
check_or_create_dir(path)
utils.check_or_create_dir(path)
assert os.path.isdir(path)
def test_url_from_path():
assert url_from_path(os.sep.join(['foo', 'bar'])) == 'foo/bar'
assert utils.url_from_path(os.sep.join(['foo', 'bar'])) == 'foo/bar'
def test_read_markdown():
src = os.path.join(SAMPLE_DIR, 'pictures', 'dir1', 'test1', '11.md')
m = utils.read_markdown(src)
assert m['title'] == "Foo Bar"
assert m['meta']['location'][0] == "Bavaria"
assert m['description'] == \
"<p>This is a funny description of this image</p>"