def get_retention_flags(self) -> List[str]: path_not_present = True flags = self.get_global_flags() for key, flag in self._retention_flags.items(): # create a restic argument for it arguments = flag.get_flags() if arguments: flags.extend(arguments) # keep track of the 'path' flag if key == constants.PARAMETER_PATH: path_not_present = False # to make sure we only deal with the current backup, we add the backup source as 'path' argument if path_not_present and self._source: path_flag = Flag(constants.PARAMETER_PATH, self._source, 'dir') flags.extend(path_flag.get_flags()) return flags
def test_can_get_dir_value(self): flag = Flag('name', "/some.dir", 'dir') argument = flag.get_flags() self.assertEqual(argument, ["--name \"/some.dir\""])
def test_can_get_string_value(self): flag = Flag('key', 'value', 'str') argument = flag.get_flags() self.assertEqual(argument, ["--key \"value\""])
def test_can_get_string_with_quote_value(self): flag = Flag('name', "o'irish", 'str') argument = flag.get_flags() self.assertEqual(argument, ["--name \"o'irish\""])
def test_can_get_file_value(self): flag = Flag('name', "some.file", 'file') argument = flag.get_flags() self.assertEqual(argument, ["--name \"some.file\""])
def test_can_get_string_values(self): flag = Flag('key', ["1", "2"], 'str') argument = flag.get_flags() self.assertEqual(argument, ["--key \"1\"", "--key \"2\""])
def test_can_get_negative_int_value(self): flag = Flag('key', -1, 'int') argument = flag.get_flags() self.assertEqual(argument, ["--key -1"])
def test_can_get_zero_int_value(self): flag = Flag('key', 0, 'int') argument = flag.get_flags() self.assertEqual(argument, ["--key 0"])
def test_can_get_false_boolean_value(self): flag = Flag('key', False, 'bool') argument = flag.get_flags() self.assertEqual(argument, [])
def test_can_get_true_boolean_value(self): flag = Flag('key', True, 'bool') argument = flag.get_flags() self.assertEqual(argument, ["--key"])