def master_child_scenario(action_resource, host, execute_resource, report_resource, scenario_resource, default_host_params, config): child_scenario = Scenario(config=Config(), parameters={'k': 'v'}) host2 = Asset( name='host02', config=config, parameters=copy.deepcopy(default_host_params) ) execute_res2 = Execute(name='execute02', config=config, parameters=dict(description='description', hosts='host02', executor='runner')) child_scenario.add_assets(host2) child_scenario.add_executes(execute_res2) scenario_resource.add_child_scenario(child_scenario) scenario_resource.add_assets(host) scenario_resource.add_actions(action_resource) scenario_resource.add_executes(execute_resource) scenario_resource.add_reports(report_resource) return scenario_resource
def test_create_execute_with_artifacts_as_str(): params = dict(description='description', hosts='host01, host02', artifacts='test.log, console.log') execute = Execute(name='execute', parameters=params) assert isinstance(execute.artifacts, list)
def test_create_execute_with_hosts_as_str(): params = dict(description='description', hosts='host01, host02') execute = Execute(name='execute', parameters=params) assert isinstance(execute.hosts, list)
def test_create_execute_without_hosts(): params = dict(hosts=None, key='value', executor='runner') with pytest.raises(TefloExecuteError) as ex: Execute(name='execute', parameters=params) assert 'Unable to associate hosts to executor:execute. No hosts ' \ 'defined!' in ex.value.args
def test_create_execute_with_invalid_executor(): params = dict(hosts=['host01'], key='value', executor='abc') with pytest.raises(TefloExecuteError) as ex: Execute(name='execute', parameters=params) assert 'Executor: abc is not supported!' in ex.value.args
def test_timeout_from_cfg(config, default_host_params): params = dict(hosts=['host01'], key='value') execute = Execute(name='action', parameters=params, config=config) assert execute._execute_timeout is 25
def test_timeout_from_scenario(timeout_param_execute): execute = Execute(name='action', parameters=timeout_param_execute) assert execute._execute_timeout is 20
def test_create_execute_without_name(): with pytest.raises(TefloExecuteError) as ex: Execute() assert 'Unable to build execute object. Name field missing!' in \ ex.value.args
def test_create_execute_with_name(): params = dict(hosts=['host01'], key='value') execute = Execute(name='execute', parameters=params) assert isinstance(execute, Execute)
def execute_resource(config): params = dict(description='description', hosts='host01', executor='runner') return Execute(name='execute', config=config, parameters=params)
def execute2(config): params = dict(description='description', hosts='group_test', executor='runner', labels='label3') return Execute(name='execute2', config=config, parameters=params)