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
29 lines
1.1 KiB
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")
|