Move cli handling to __main__
This commit is contained in:
@@ -4,7 +4,7 @@ from os.path import join
|
||||
|
||||
from click.testing import CliRunner
|
||||
|
||||
from sigal import build, init, serve, set_meta
|
||||
from sigal.__main__ import build, init, serve, set_meta
|
||||
|
||||
TESTGAL = join(os.path.abspath(os.path.dirname(__file__)), "sample")
|
||||
|
||||
@@ -41,15 +41,20 @@ def test_build(tmpdir, disconnect_signals):
|
||||
)
|
||||
|
||||
result = runner.invoke(build, ["-n", 1, "--debug"])
|
||||
assert result.output == "Settings file not found: sigal.conf.py\n"
|
||||
assert result.exit_code == 1
|
||||
|
||||
os.chdir(tmpdir)
|
||||
|
||||
result = runner.invoke(build, ["foo", "-n", 1, "--debug"])
|
||||
assert result.exit_code == 1
|
||||
assert "Input directory not found" in result.output
|
||||
|
||||
result = runner.invoke(build, ["pictures", "pictures/out", "-n", 1, "--debug"])
|
||||
assert result.exit_code == 1
|
||||
assert (
|
||||
"Output directory should be outside of the input directory" in result.output
|
||||
)
|
||||
|
||||
with open(config_file) as f:
|
||||
text = f.read()
|
||||
@@ -59,7 +64,7 @@ theme = 'colorbox'
|
||||
files_to_copy = (('../watermark.png', 'watermark.png'),)
|
||||
plugins = ['sigal.plugins.adjust', 'sigal.plugins.copyright',
|
||||
'sigal.plugins.watermark', 'sigal.plugins.feeds',
|
||||
'sigal.plugins.media_page' 'sigal.plugins.nomedia',
|
||||
'sigal.plugins.media_page', 'sigal.plugins.nomedia',
|
||||
'sigal.plugins.extended_caching']
|
||||
copyright = "An example copyright message"
|
||||
copyright_text_font = "foobar"
|
||||
@@ -74,7 +79,9 @@ atom_feed = {'feed_url': 'http://example.org/feed.atom', 'nb_items': 10}
|
||||
f.write(text)
|
||||
|
||||
result = runner.invoke(
|
||||
build, ["pictures", "build", "--title", "Testing build", "-n", 1, "--debug"]
|
||||
build,
|
||||
["pictures", "build", "--title", "Testing build", "-n", 1, "--debug"],
|
||||
catch_exceptions=False,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert os.path.isfile(
|
||||
|
||||
@@ -4,9 +4,9 @@ from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from sigal import init_plugins
|
||||
from sigal.gallery import Gallery
|
||||
from sigal.plugins import compress_assets
|
||||
from sigal.utils import init_plugins
|
||||
|
||||
CURRENT_DIR = os.path.dirname(__file__)
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ from io import BytesIO
|
||||
|
||||
import pytest
|
||||
|
||||
from sigal import init_plugins
|
||||
from sigal.gallery import Gallery
|
||||
from sigal.plugins.encrypt import endec
|
||||
from sigal.plugins.encrypt.encrypt import cache_key
|
||||
from sigal.utils import init_plugins
|
||||
|
||||
CURRENT_DIR = os.path.dirname(__file__)
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
from PIL import Image as PILImage
|
||||
|
||||
from sigal import init_logging
|
||||
from sigal.gallery import Image
|
||||
from sigal.image import (
|
||||
generate_image,
|
||||
@@ -16,6 +15,7 @@ from sigal.image import (
|
||||
get_size,
|
||||
process_image,
|
||||
)
|
||||
from sigal.log import init_logging
|
||||
from sigal.settings import Status, create_settings
|
||||
|
||||
CURRENT_DIR = os.path.dirname(__file__)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
|
||||
from sigal import init_plugins
|
||||
from sigal.gallery import Gallery
|
||||
from sigal.utils import init_plugins
|
||||
|
||||
CURRENT_DIR = os.path.dirname(__file__)
|
||||
|
||||
|
||||
@@ -43,16 +43,43 @@ def test_copy(tmpdir):
|
||||
utils.copy(src, dst)
|
||||
utils.copy(src, dst)
|
||||
|
||||
|
||||
def test_force(tmpdir):
|
||||
assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', False) is False
|
||||
assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', True) is True
|
||||
assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', ['Gallery/*']) is True
|
||||
assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', ['Gallery/*Pics']) is True
|
||||
assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', ['Pictures/*']) is False
|
||||
assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', ['New Pics']) is True
|
||||
assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', ['Pictures']) is False
|
||||
assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', ['Pictures', 'Something']) is False
|
||||
assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', ['Pictures', 'Gallery', '*Pics']) is True
|
||||
assert utils.should_reprocess_album("Gallery/New Pics", "New Pics", False) is False
|
||||
assert utils.should_reprocess_album("Gallery/New Pics", "New Pics", True) is True
|
||||
assert (
|
||||
utils.should_reprocess_album("Gallery/New Pics", "New Pics", ["Gallery/*"])
|
||||
is True
|
||||
)
|
||||
assert (
|
||||
utils.should_reprocess_album("Gallery/New Pics", "New Pics", ["Gallery/*Pics"])
|
||||
is True
|
||||
)
|
||||
assert (
|
||||
utils.should_reprocess_album("Gallery/New Pics", "New Pics", ["Pictures/*"])
|
||||
is False
|
||||
)
|
||||
assert (
|
||||
utils.should_reprocess_album("Gallery/New Pics", "New Pics", ["New Pics"])
|
||||
is True
|
||||
)
|
||||
assert (
|
||||
utils.should_reprocess_album("Gallery/New Pics", "New Pics", ["Pictures"])
|
||||
is False
|
||||
)
|
||||
assert (
|
||||
utils.should_reprocess_album(
|
||||
"Gallery/New Pics", "New Pics", ["Pictures", "Something"]
|
||||
)
|
||||
is False
|
||||
)
|
||||
assert (
|
||||
utils.should_reprocess_album(
|
||||
"Gallery/New Pics", "New Pics", ["Pictures", "Gallery", "*Pics"]
|
||||
)
|
||||
is True
|
||||
)
|
||||
|
||||
|
||||
def test_check_or_create_dir(tmpdir):
|
||||
path = str(tmpdir.join("new_directory"))
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import os
|
||||
import zipfile
|
||||
|
||||
from sigal import init_plugins
|
||||
from sigal.gallery import Gallery
|
||||
from sigal.settings import read_settings
|
||||
from sigal.utils import init_plugins
|
||||
|
||||
CURRENT_DIR = os.path.dirname(__file__)
|
||||
SAMPLE_DIR = os.path.join(CURRENT_DIR, "sample")
|
||||
|
||||
Reference in New Issue
Block a user