Beispiel #1
0
def test_run_script_returns_RunResult():
    executer_mock = Mock()
    parsed_build_structure = ParsedBuildStructure()

    executer_mock.expects(once()).method('execute_target').with_at_least(build_structure=eq(parsed_build_structure), target=eq(None))

    parser_mock = Mock()
    parsed_build_structure.targets["some target"] = None
    parser_mock.expects(once()).parse_script(eq("some script")).will(return_value(parsed_build_structure))

    runner = Runner(parser=parser_mock, executer=executer_mock)
    result = runner.run("some script", "some target")
    assert isinstance(result, RunResult)
    parser_mock.verify()
Beispiel #2
0
def test_run_script_returns_proper_result():
    some_result = RunResult()
    some_result.log = "some log"
    some_result.status = Successful

    mock_target = Mock()
    executer_mock = Mock()
    parser_mock = Mock()
    parsed_build_structure = ParsedBuildStructure()
    parsed_build_structure.log_entries = ["some log"]
    parsed_build_structure.targets["some target"] = mock_target
    parser_mock.expects(once()).parse_script(eq("some script")).will(return_value(parsed_build_structure))

    executer_mock.expects(once()).method('execute_target').with_at_least(build_structure=eq(parsed_build_structure), target=eq(mock_target))

    runner = Runner(parser=parser_mock, executer=executer_mock)
    result = runner.run("some script", "some target")

    assert result.status == Successful
    parser_mock.verify()
    mock_target.verify()
    executer_mock.verify()