import pytest from tibi_hardlinks.backups import create_backup_directory_name from tibi_hardlinks.exceptions import ConfigurationException @pytest.mark.usefixtures("canned_data_output") @pytest.mark.parametrize("filename", ["example-old", "example-new"]) def test_filename_good_canned(filename, canned_data_output): data = canned_data_output(filename) filenames = { "example-old": "XT1095/TA44909SO3/QPython3/1.0.3/2017-11-01_07-38-42", "example-new": "OnePlus 7 Pro/7ea4c847/Luis.Babyphone/2.0.72/2020-10-30_09-12-41", } generated_filename = create_backup_directory_name(data) assert filenames[filename] == str(generated_filename) def test_filename_raise_on_bad_time_format(canned_data_output): data = canned_data_output("example-new") with pytest.raises(ConfigurationException): create_backup_directory_name(data, "obviously bogus time format") def test_filename_raise_on_incomplete_exception(canned_data_output): data = canned_data_output("example-new") with pytest.raises(ConfigurationException): create_backup_directory_name(data, "%Y-%M-%D")