本文整理汇总了Python中tests.test_utils.create_script_param_config函数的典型用法代码示例。如果您正苦于以下问题:Python create_script_param_config函数的具体用法?Python create_script_param_config怎么用?Python create_script_param_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_script_param_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parameter_secure_value_and_same_unsecure
def test_parameter_secure_value_and_same_unsecure(self):
p1 = create_script_param_config('p1', param='-p1', secure=True)
p2 = create_script_param_config('p2', param='-p2')
secure_command = self.get_secure_command([p1, p2], {'p1': 'value', 'p2': 'value'})
self.assertEqual('ls -p1 ****** -p2 value', secure_command)
示例2: test_logging_values
def test_logging_values(self):
param1 = create_script_param_config('p1')
param2 = create_script_param_config('p2', param='-x')
param3 = create_script_param_config('p3', param='-y', no_value=True)
param4 = create_script_param_config('p4', param='-z', type='int')
config_model = create_config_model(
'my_script', script_command='echo', parameters=[param1, param2, param3, param4])
execution_id = self.executor_service.start_script(
config_model,
{'p1': 'abc', 'p3': True, 'p4': 987},
'userX',
create_audit_names(ip='localhost', auth_username='sandy'))
executor = self.executor_service.get_active_executor(execution_id)
executor.process_wrapper._write_script_output('some text\n')
executor.process_wrapper._write_script_output('another text')
executor.process_wrapper.finish(0)
wait_observable_close_notification(executor.get_anonymized_output_stream(), 2)
entry = self.logging_service.find_history_entry(execution_id)
self.assertIsNotNone(entry)
self.assertEqual('userX', entry.user_id)
self.assertEqual('sandy', entry.user_name)
self.assertEqual('my_script', entry.script_name)
self.assertEqual('echo abc -y -z 987', entry.command)
self.assertEqual('my_script', entry.script_name)
log = self.logging_service.find_log(execution_id)
self.assertEqual('some text\nanother text', log)
示例3: test_get_parameter_values_when_invalid_value
def test_get_parameter_values_when_invalid_value(self):
parameters = [
create_script_param_config('p1', type='int'),
create_script_param_config('dependant', type='list', values_script='echo "${p1}"')
]
config_model = _create_config_model('conf_x', parameters=parameters)
self.assertRaises(InvalidValueException, config_model.set_param_value, 'p1', 'ABC')
示例4: test_set_all_values_when_dependants_cylce
def test_set_all_values_when_dependants_cylce(self):
parameters = [
create_script_param_config('p1', type='list', values_script='echo "X${p2}X"'),
create_script_param_config('p2', type='list', values_script='echo "X${p1}X"')]
config_model = _create_config_model('main_conf', parameters=parameters)
values = {'p1': 'XabcX', 'p2': 'abc'}
self.assertRaisesRegex(Exception, 'Could not resolve order', config_model.set_all_param_values, values)
示例5: test_get_required_parameters
def test_get_required_parameters(self):
parameters = [
create_script_param_config('p1'),
create_script_param_config('dependant', type='list', values_script='echo "${p1}""${p2}"'),
create_script_param_config('p2')
]
config_model = _create_config_model('conf_x', parameters=parameters)
dependant_parameter = config_model.find_parameter('dependant')
self.assertCountEqual(['p1', 'p2'], dependant_parameter.get_required_parameters())
示例6: test_set_all_values_with_normalization
def test_set_all_values_with_normalization(self):
allowed_values = ['abc', 'def', 'xyz']
parameters = [
create_script_param_config('p1', type=PARAM_TYPE_MULTISELECT, allowed_values=allowed_values),
create_script_param_config('p2', type=PARAM_TYPE_MULTISELECT, allowed_values=allowed_values),
create_script_param_config('p3', type=PARAM_TYPE_MULTISELECT, allowed_values=allowed_values)]
config_model = _create_config_model('config', parameters=parameters)
config_model.set_all_param_values({'p1': '', 'p2': ['def'], 'p3': 'abc'})
self.assertEqual({'p1': [], 'p2': ['def'], 'p3': ['abc']}, config_model.parameter_values)
示例7: test_set_all_values_when_dependant_before_required
def test_set_all_values_when_dependant_before_required(self):
parameters = [
create_script_param_config('dep_p2', type='list', values_script='echo "X${p1}X"'),
create_script_param_config('p1')]
config_model = _create_config_model('main_conf', parameters=parameters)
values = {'dep_p2': 'XabcX', 'p1': 'abc'}
config_model.set_all_param_values(values)
self.assertEqual(values, config_model.parameter_values)
示例8: test_create_with_parameters_and_default_values
def test_create_with_parameters_and_default_values(self):
parameters = [create_script_param_config('param1', default='123'),
create_script_param_config('param2'),
create_script_param_config('param3', default='A')]
config_model = _create_config_model('conf_with_defaults', parameters=parameters)
self.assertEqual(3, len(config_model.parameters))
values = config_model.parameter_values
self.assertEqual('123', values.get('param1'))
self.assertIsNone(values.get('param2'))
self.assertEqual('A', values.get('param3'))
示例9: test_dynamic_include_add_2_parameters_with_default_when_one_dependant
def test_dynamic_include_add_2_parameters_with_default_when_one_dependant(self):
(config_model, included_path) = self.prepare_config_model_with_included([
create_script_param_config('included_param1', default='ABC'),
create_script_param_config('included_param2', default='xABCx', type='list',
values_script='echo x${included_param1}x'),
], 'p1')
self.assertEqual('ABC', config_model.parameter_values.get('included_param1'))
self.assertEqual('xABCx', config_model.parameter_values.get('included_param2'))
dependant_parameter = config_model.find_parameter('included_param2')
self.assertEqual(['xABCx'], dependant_parameter.values)
示例10: test_dynamic_include_remove_multiple_parameters
def test_dynamic_include_remove_multiple_parameters(self):
(config_model, included_path) = self.prepare_config_model_with_included([
create_script_param_config('included_param1'),
create_script_param_config('included_param2'),
create_script_param_config('included_param3')
], 'p1')
config_model.set_param_value('p1', '')
self.assertEqual(1, len(config_model.parameters))
included_param = config_model.parameters[0]
self.assertEqual('p1', included_param.name)
示例11: test_static_include_ignore_same_parameter
def test_static_include_ignore_same_parameter(self):
included_path = test_utils.write_script_config({'parameters': [
create_script_param_config('param1', type='int', required=False)
]}, 'included')
config_model = _create_config_model('main_conf', config={
'include': included_path,
'parameters': [create_script_param_config('param1', type='text', required=True)]})
self.assertEqual(1, len(config_model.parameters))
param1 = config_model.parameters[0]
self.assertEqual('text', param1.type)
self.assertEqual(True, param1.required)
示例12: test_get_parameter_values_simple
def test_get_parameter_values_simple(self):
parameters = [
create_script_param_config('p1'),
create_script_param_config('dependant',
type='list',
values_script="echo '${p1}\n' '_${p1}_\n' '${p1}${p1}\n'")
]
config_model = _create_config_model('conf_x', parameters=parameters)
config_model.set_param_value('p1', 'ABC')
dependant_parameter = config_model.find_parameter('dependant')
self.assertEqual(['ABC', ' _ABC_', ' ABCABC'], dependant_parameter.values)
示例13: test_create_with_parameters_and_custom_values
def test_create_with_parameters_and_custom_values(self):
parameters = [create_script_param_config('param1', default='def1'),
create_script_param_config('param2', default='def2'),
create_script_param_config('param3', default='def3')]
parameter_values = {'param1': '123', 'param3': True}
config_model = _create_config_model('conf_with_defaults', parameters=parameters,
parameter_values=parameter_values)
self.assertEqual(3, len(config_model.parameters))
values = config_model.parameter_values
self.assertEqual('123', values.get('param1'))
self.assertIsNone(values.get('param2'))
self.assertEqual(True, values.get('param3'))
示例14: test_dynamic_include_replace
def test_dynamic_include_replace(self):
(config_model, included_path1) = self.prepare_config_model_with_included([
create_script_param_config('included_param_X')
], 'p1')
included_path2 = test_utils.write_script_config({'parameters': [
create_script_param_config('included_param_Y')
]}, 'included2')
config_model.set_param_value('p1', included_path2)
self.assertEqual(2, len(config_model.parameters))
self.assertEqual('p1', config_model.parameters[0].name)
self.assertEqual('included_param_Y', config_model.parameters[1].name)
示例15: test_output_files_with_secure_parameters
def test_output_files_with_secure_parameters(self):
test_utils.create_file('file1.txt', text='hello world')
file2 = test_utils.create_file(os.path.join('sub', 'child', 'admin.log'), text='password=123')
param1 = create_script_param_config('p1', secure=True)
param2 = create_script_param_config('p2')
downloadable_files = self.perform_execution([
os.path.join(test_utils.temp_folder, '${p1}.txt'),
os.path.join(test_utils.temp_folder, 'sub', '${p2}', 'admin.log')],
parameter_values={'p1': 'file1', 'p2': 'child'},
parameters=[param1, param2])
self.assert_downloadable_files(downloadable_files, [file2])