mirror of
https://github.com/venthur/blag.git
synced 2025-11-25 20:52:43 +00:00
put fixtures into conftest
This commit is contained in:
@@ -7,19 +7,15 @@ import pytest
|
|||||||
from blag import blag
|
from blag import blag
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
def test_generate_feed(tempdir):
|
||||||
def outdir():
|
outdir = f'{tempdir}/build'
|
||||||
with TemporaryDirectory() as dir:
|
|
||||||
yield dir
|
|
||||||
|
|
||||||
|
|
||||||
def test_generate_feed(outdir):
|
|
||||||
articles = []
|
articles = []
|
||||||
blag.generate_feed(articles, outdir, ' ', ' ', ' ', ' ')
|
blag.generate_feed(articles, outdir, ' ', ' ', ' ', ' ')
|
||||||
assert os.path.exists(f'{outdir}/atom.xml')
|
assert os.path.exists(f'{outdir}/atom.xml')
|
||||||
|
|
||||||
|
|
||||||
def test_feed(outdir):
|
def test_feed(tempdir):
|
||||||
|
outdir = f'{tempdir}/build'
|
||||||
articles = [
|
articles = [
|
||||||
[
|
[
|
||||||
'dest1.html',
|
'dest1.html',
|
||||||
@@ -66,7 +62,8 @@ def test_feed(outdir):
|
|||||||
assert '<link href="https://example.com/dest2.html"' in feed
|
assert '<link href="https://example.com/dest2.html"' in feed
|
||||||
|
|
||||||
|
|
||||||
def test_generate_feed_with_description(outdir):
|
def test_generate_feed_with_description(tempdir):
|
||||||
|
outdir = f'{tempdir}/build'
|
||||||
# if a description is provided, it will be used as the summary in
|
# if a description is provided, it will be used as the summary in
|
||||||
# the feed, otherwise we simply use the title of the article
|
# the feed, otherwise we simply use the title of the article
|
||||||
articles = [[
|
articles = [[
|
||||||
|
|||||||
@@ -1,17 +1,8 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from tempfile import TemporaryDirectory
|
|
||||||
from blag import devserver
|
from blag import devserver
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def tempdir():
|
|
||||||
with TemporaryDirectory() as dir:
|
|
||||||
yield dir
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_last_modified(tempdir):
|
def test_get_last_modified(tempdir):
|
||||||
# take initial time
|
# take initial time
|
||||||
t1 = devserver.get_last_modified([tempdir])
|
t1 = devserver.get_last_modified([tempdir])
|
||||||
|
|||||||
@@ -1,46 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from blag import blag
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def environment():
|
|
||||||
site = {
|
|
||||||
'base_url': 'site base_url',
|
|
||||||
'title': 'site title',
|
|
||||||
'description': 'site description',
|
|
||||||
'author': 'site author',
|
|
||||||
}
|
|
||||||
env = blag.environment_factory(globals_=dict(site=site))
|
|
||||||
yield env
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def page_template(environment):
|
|
||||||
yield environment.get_template('page.html')
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def article_template(environment):
|
|
||||||
yield environment.get_template('article.html')
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def archive_template(environment):
|
|
||||||
yield environment.get_template('archive.html')
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def tags_template(environment):
|
|
||||||
yield environment.get_template('tags.html')
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def tag_template(environment):
|
|
||||||
yield environment.get_template('tag.html')
|
|
||||||
|
|
||||||
|
|
||||||
def test_page(page_template):
|
def test_page(page_template):
|
||||||
ctx = {
|
ctx = {
|
||||||
|
|||||||
Reference in New Issue
Block a user