Browse Source

Make sure zip_gallery is set correctly (fix #477)

pull/480/head
Simon Conseil 4 years ago
parent
commit
272f33266d
  1. 7
      sigal/plugins/zip_gallery.py
  2. 11
      tests/test_zip.py

7
sigal/plugins/zip_gallery.py

@ -111,5 +111,12 @@ def nozip_gallery_file(album, settings=None):
Album.zip.__set_name__(Album, 'zip') Album.zip.__set_name__(Album, 'zip')
def check_settings(gallery):
if gallery.settings['zip_gallery'] and not isinstance(gallery.settings['zip_gallery'], str):
logger.error("'zip_gallery' should be set to a filename")
gallery.settings['zip_gallery'] = False
def register(settings): def register(settings):
signals.album_initialized.connect(nozip_gallery_file) signals.album_initialized.connect(nozip_gallery_file)
signals.gallery_initialized.connect(check_settings)

11
tests/test_zip.py

@ -61,3 +61,14 @@ def test_no_archive(tmpdir):
assert not os.path.isfile(os.path.join(outpath, 'test1', 'archive.zip')) assert not os.path.isfile(os.path.join(outpath, 'test1', 'archive.zip'))
assert not os.path.isfile(os.path.join(outpath, 'test2', 'archive.zip')) assert not os.path.isfile(os.path.join(outpath, 'test2', 'archive.zip'))
def test_correct_filename(tmpdir, caplog):
caplog.set_level('ERROR')
outpath = str(tmpdir)
gallery = make_gallery(destination=outpath, zip_gallery=True)
gallery.build()
assert caplog.records[0].message == "'zip_gallery' should be set to a filename"
assert not os.path.isfile(os.path.join(outpath, 'test1', 'archive.zip'))
assert not os.path.isfile(os.path.join(outpath, 'test2', 'archive.zip'))

Loading…
Cancel
Save