You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.1 KiB

5 years ago
5 years ago
  1. import pytest
  2. from tibi_hardlinks.backups import create_backup_directory_name
  3. from tibi_hardlinks.exceptions import ConfigurationException
  4. @pytest.mark.usefixtures("canned_data_output")
  5. @pytest.mark.parametrize("filename", ["example-old", "example-new"])
  6. def test_filename_good_canned(filename, canned_data_output):
  7. data = canned_data_output(filename)
  8. filenames = {
  9. "example-old": "XT1095/TA44909SO3/QPython3/1.0.3/2017-11-01_07-38-42",
  10. "example-new": "OnePlus 7 Pro/7ea4c847/Luis.Babyphone/2.0.72/2020-10-30_09-12-41",
  11. }
  12. generated_filename = create_backup_directory_name(data)
  13. assert filenames[filename] == str(generated_filename)
  14. def test_filename_raise_on_bad_time_format(canned_data_output):
  15. data = canned_data_output("example-new")
  16. with pytest.raises(ConfigurationException):
  17. create_backup_directory_name(data, "obviously bogus time format")
  18. def test_filename_raise_on_incomplete_exception(canned_data_output):
  19. data = canned_data_output("example-new")
  20. with pytest.raises(ConfigurationException):
  21. create_backup_directory_name(data, "%Y-%M-%D")