def test_load_configuration_parses_restic_config( backup_dest_dirs: list[str], backup_repository_folder: str, device_pass_cmd: str, repository_pass_cmd: str, uuid: UUID, ) -> None: with TemporaryDirectory() as source: restic_cfg = cp.ResticConfig( BackupRepositoryFolder=backup_repository_folder, DevicePassCmd=device_pass_cmd, FilesAndFolders={Path(source)}, RepositoryPassCmd=repository_pass_cmd, UUID=uuid, ) cfg_lst = cp.parse_configuration(f"[{restic_cfg.json()}]") assert cfg_lst == [restic_cfg]
def test_parse_configuration_parses_btrfs_config( backup_dest_dirs: list[str], backup_repository_folder: str, pass_cmd: str, uuid: UUID, ) -> None: with TemporaryDirectory() as source: btrfs_cfg = cp.BtrfsConfig( BackupRepositoryFolder=backup_repository_folder, DevicePassCmd=pass_cmd, Files=set(), FilesDest=backup_dest_dirs[1], Folders={Path(source): backup_dest_dirs[0]}, UUID=uuid, ) cfg_lst = cp.parse_configuration(f"[{btrfs_cfg.json()}]") assert cfg_lst == [btrfs_cfg]
def test_parse_configuration_warns_on_non_lists(non_list) -> None: with pytest.raises(ValidationError): cp.parse_configuration(json.dumps(non_list))
def test_parse_configuration_warns_on_non_dict_item() -> None: with pytest.raises(ValidationError): cp.parse_configuration(json.dumps([{}, 1337]))
def test_parse_configuration_rejects_empty_list() -> None: with pytest.raises(SystemExit) as sysexit: cp.parse_configuration("[]") assert sysexit.value.code not in SUCCESS_CODES