本文整理汇总了Python中tests.test_utils.create_parameter_model函数的典型用法代码示例。如果您正苦于以下问题:Python create_parameter_model函数的具体用法?Python create_parameter_model怎么用?Python create_parameter_model使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_parameter_model函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_multiple_parameters_get_required
def test_multiple_parameters_get_required(self):
self.add_parameter(create_parameter_model('p1'))
self.add_parameter(create_parameter_model('p2'))
self.add_parameter(create_parameter_model('p3'))
property = self.create_property('Hello ${p1}, ${p3} and ${p2}!')
self.assertCountEqual(['p1', 'p2', 'p3'], property.required_parameters)
示例2: test_multiple_parameters_when_one_repeats
def test_multiple_parameters_when_one_repeats(self):
self.add_parameter(create_parameter_model('p1'))
self.add_parameter(create_parameter_model('p2'))
property = self.create_property('Hello ${p1}, ${p1}, ${p2} and ${p1}!')
self.set_value('p1', 'John')
self.set_value('p2', 'Mary')
self.assertEqual('Hello John, John, Mary and John!', property.get())
示例3: test_two_replaces_in_two_files
def test_two_replaces_in_two_files(self):
parameters = []
parameters.append(create_parameter_model('param1', all_parameters=parameters))
parameters.append(create_parameter_model('param2', all_parameters=parameters))
files = file_download_feature.substitute_parameter_values(
parameters,
['/home/${param2}/${param1}.txt', '/tmp/${param2}.txt', '/${param1}'],
{'param1': 'val1', 'param2': 'val2'})
self.assertEqual(files, ['/home/val2/val1.txt', '/tmp/val2.txt', '/val1'])
示例4: test_multiple_parameters_when_one_missing
def test_multiple_parameters_when_one_missing(self):
self.add_parameter(create_parameter_model('p1'))
self.add_parameter(create_parameter_model('p2'))
self.add_parameter(create_parameter_model('p3'))
property = self.create_property('Hello, ${p1}, ${p2} and ${p3}!')
self.set_value('p1', 'John')
self.set_value('p3', 'world')
self.assertIsNone(property.get())
示例5: test_multiple_parameters
def test_multiple_parameters(self):
self.add_parameter(create_parameter_model('p1'))
self.add_parameter(create_parameter_model('p2'))
self.add_parameter(create_parameter_model('p3'))
property = self.create_property('Hello, ${p1}, ${p2} and ${p3}!')
self.set_value('p1', 'John')
self.set_value('p2', 'Mary')
self.set_value('p3', 'world')
self.assertEqual('Hello, John, Mary and world!', property.get())
示例6: test_list_with_dependency_when_matches
def test_list_with_dependency_when_matches(self):
parameters = []
values = ObservableDict()
dep_param = create_parameter_model('dep_param')
parameter = create_parameter_model('param',
type='list',
values_script="echo '${dep_param}_\n' '_${dep_param}_'",
all_parameters=parameters,
other_param_values=values)
parameters.extend([dep_param, parameter])
values['dep_param'] = 'abc'
error = parameter.validate_value(' _abc_')
self.assertIsNone(error)
示例7: create_parameters
def create_parameters(self, *names):
result = []
for name in names:
parameter = create_parameter_model(name, all_parameters=result)
result.append(parameter)
return result
示例8: test_map_to_script_file_value
def test_map_to_script_file_value(self):
file_dir = os.path.expanduser('~')
parameter_model = create_parameter_model('param1', type=PARAM_TYPE_SERVER_FILE,
file_dir=file_dir)
mapped_value = parameter_model.map_to_script('abc')
self.assertEqual(os.path.join(file_dir, 'abc'), mapped_value)
示例9: test_late_add_single_parameter
def test_late_add_single_parameter(self):
self.set_value('p1', 'John')
property = self.create_property('Hello, ${p1}!')
self.add_parameter(create_parameter_model('p1'))
self.assertEqual('Hello, John!', property.get())
示例10: test_server_file_when_valid
def test_server_file_when_valid(self):
filename = 'file1.txt'
test_utils.create_file(filename)
parameter = create_parameter_model('param', type=PARAM_TYPE_SERVER_FILE, file_dir=test_utils.temp_folder)
error = parameter.validate_value(filename)
self.assertIsNone(error)
示例11: test_late_remove_single_parameter
def test_late_remove_single_parameter(self):
parameter = create_parameter_model('p1')
self.add_parameter(parameter)
self.set_value('p1', 'John')
property = self.create_property('Hello, ${p1}!')
self.parameters.remove(parameter)
self.assertEqual('Hello, ${p1}!', property.get())
示例12: test_skip_flag_replace
def test_skip_flag_replace(self):
param1 = create_parameter_model('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'])
示例13: test_notification_on_parameter_add
def test_notification_on_parameter_add(self):
config = _create_config_model('conf_x')
observer = self._create_collection_observer()
config.parameters.subscribe(observer)
parameter = create_parameter_model('param1')
config.parameters.append(parameter)
self.assertEqual([('add', parameter)], observer.changes)
示例14: test_single_replace
def test_single_replace(self):
parameter = create_parameter_model('param1')
files = file_download_feature.substitute_parameter_values(
[parameter],
['/home/user/${param1}.txt'],
{'param1': 'val1'})
self.assertEqual(files, ['/home/user/val1.txt'])
示例15: test_no_pattern_match
def test_no_pattern_match(self):
param1 = create_parameter_model('param1')
files = file_download_feature.substitute_parameter_values(
[param1],
['/home/user/${paramX}.txt'],
{'param1': 'val1'})
self.assertEqual(files, ['/home/user/${paramX}.txt'])