# pylint: disable=missing-function-docstring """ Tests on opening hours helpers """ import datetime import os import pytest from mylib.telltale import TelltaleFile def test_create_telltale_file(tmp_path): filename = "test" file = TelltaleFile(filename=filename, dirpath=tmp_path) assert file.filename == filename assert file.dirpath == tmp_path assert file.filepath == os.path.join(tmp_path, filename) assert not os.path.exists(file.filepath) assert file.last_update is None file.update() assert os.path.exists(file.filepath) assert isinstance(file.last_update, datetime.datetime) def test_create_telltale_file_with_filepath_and_invalid_dirpath(): with pytest.raises(AssertionError): TelltaleFile(filepath="/tmp/test", dirpath="/var/tmp") # nosec: B108 def test_create_telltale_file_with_filepath_and_invalid_filename(): with pytest.raises(AssertionError): TelltaleFile(filepath="/tmp/test", filename="other") # nosec: B108 def test_remove_telltale_file(tmp_path): file = TelltaleFile(filename="test", dirpath=tmp_path) file.update() assert file.remove()