# SPDX-License-Identifier: GPL-3.0 import os from fotogrid import fotogrid from lxml import etree from io import StringIO def check_if_valid_html(html): """ GIVEN an html string WHEN parsing the html string results in an error THEN assert """ parser = etree.HTMLParser(recover=False) etree.parse(StringIO(html), parser) assert len(parser.error_log) == 0 def test_fotogrid_empty_list(): """ WHEN creating a fotogrid without any image url THEN expecting an empty result (no html code at all) """ html = fotogrid([]) assert len(html) == 0 def check_if_images_result_in(nbr_of_images, rows_expected, cols_expected): urls = ["dummy.jpg"] * nbr_of_images html = fotogrid(urls) check_if_valid_html(html) assert html.count("fotorow") == rows_expected assert html.count("fotocol") == cols_expected assert html.count("