def test_no_pattern_match(self): param1 = Parameter() param1.name = 'param1' files = file_download_feature.substitute_parameter_values( [param1], ['/home/user/${paramX}.txt'], {'param1': 'val1'}) self.assertEqual(files, ['/home/user/${paramX}.txt'])
def test_single_replace(self): parameter = Parameter() parameter.name = 'param1' files = file_download_feature.substitute_parameter_values( [parameter], ['/home/user/${param1}.txt'], {'param1': 'val1'}) self.assertEqual(files, ['/home/user/val1.txt'])
def test_skip_flag_replace(self): param1 = Parameter() param1.name = 'param1' param1.no_value = True files = file_download_feature.substitute_parameter_values( [param1], ['/home/user/${param1}.txt'], {'param1': 'val1'}) self.assertEqual(files, ['/home/user/${param1}.txt'])
def create_parameters(self, *param_names): result = [] for param_name in param_names: parameter = Parameter() parameter.name = param_name result.append(parameter) return result
def test_two_replaces(self): param1 = Parameter() param1.name = 'param1' param2 = Parameter() param2.name = 'param2' files = file_download_feature.substitute_parameter_values( [param1, param2], ['/home/${param2}/${param1}.txt'], { 'param1': 'val1', 'param2': 'val2' }) self.assertEqual(files, ['/home/val2/val1.txt'])
def get_default(parameter: Parameter): default = parameter.get_default() if not default: return default return unwrap_conf_value(default)