Browse Source

Fixed my tests and changes

pull/491/head
Sean Grider 3 years ago
parent
commit
81c0d81e80
  1. 3
      src/sigal/gallery.py
  2. 1
      src/sigal/utils.py
  3. 18
      tests/test_utils.py

3
src/sigal/gallery.py

@ -38,7 +38,6 @@ from itertools import cycle
from os.path import isfile, join, splitext from os.path import isfile, join, splitext
from shutil import get_terminal_size from shutil import get_terminal_size
from urllib.parse import quote as url_quote from urllib.parse import quote as url_quote
from fnmatch import fnmatch
from click import progressbar from click import progressbar
from natsort import natsort_keygen, ns from natsort import natsort_keygen, ns
@ -938,7 +937,7 @@ class Gallery:
def process_dir(self, album, force=False): def process_dir(self, album, force=False):
"""Process a list of images in a directory.""" """Process a list of images in a directory."""
for f in album: for f in album:
if isfile(f.dst_path) and not should_reprocess_album(a.path, a.name, force): if isfile(f.dst_path) and not should_reprocess_album(album.path, album.name, force):
self.logger.info("%s exists - skipping", f.dst_filename) self.logger.info("%s exists - skipping", f.dst_filename)
self.stats[f.type + "_skipped"] += 1 self.stats[f.type + "_skipped"] += 1
else: else:

1
src/sigal/utils.py

@ -23,6 +23,7 @@ import os
import shutil import shutil
from functools import lru_cache from functools import lru_cache
from urllib.parse import quote from urllib.parse import quote
from fnmatch import fnmatch
from markdown import Markdown from markdown import Markdown
from markupsafe import Markup from markupsafe import Markup

18
tests/test_utils.py

@ -44,15 +44,15 @@ def test_copy(tmpdir):
utils.copy(src, dst) utils.copy(src, dst)
def test_force(tmpdir): def test_force(tmpdir):
assert should_reprocess_album('Gallery/New Pics', 'New Pics', False) is False assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', False) is False
assert should_reprocess_album('Gallery/New Pics', 'New Pics', True) is True assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', True) is True
assert should_reprocess_album('Gallery/New Pics', 'New Pics', ['Gallery/*']) is True assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', ['Gallery/*']) is True
assert should_reprocess_album('Gallery/New Pics', 'New Pics', ['Gallery/*Pics']) is True assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', ['Gallery/*Pics']) is True
assert should_reprocess_album('Gallery/New Pics', 'New Pics', ['Pictures/*']) is False assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', ['Pictures/*']) is False
assert should_reprocess_album('Gallery/New Pics', 'New Pics', ['New Pics']) is True assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', ['New Pics']) is True
assert should_reprocess_album('Gallery/New Pics', 'New Pics', ['Pictures']) is False assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', ['Pictures']) is False
assert should_reprocess_album('Gallery/New Pics', 'New Pics', ['Pictures', 'Something']) is False assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', ['Pictures', 'Something']) is False
assert should_reprocess_album('Gallery/New Pics', 'New Pics', ['Pictures', 'Gallery', '*Pics']) is True assert utils.should_reprocess_album('Gallery/New Pics', 'New Pics', ['Pictures', 'Gallery', '*Pics']) is True
def test_check_or_create_dir(tmpdir): def test_check_or_create_dir(tmpdir):
path = str(tmpdir.join("new_directory")) path = str(tmpdir.join("new_directory"))

Loading…
Cancel
Save