Exemplo n.º 1
0
def test_get_last_step_build_requests_no_executedSteps():
    step = steps.ReduceTriggerProperties(reducefn=lambda: None)

    step.build = None

    with pytest.raises(RuntimeError):
        step.get_last_step_build_requests()
Exemplo n.º 2
0
def test_get_last_step_build_requests_step_is_not_trigger():
    step = steps.ReduceTriggerProperties(reducefn=lambda: None)

    class FakeBuild:
        executedSteps = [object(), step]

    step.build = FakeBuild()

    with pytest.raises(TypeError):
        step.get_last_step_build_requests()
Exemplo n.º 3
0
def test_get_last_step_build_requests_no_enough_executed_steps():
    step = steps.ReduceTriggerProperties(reducefn=lambda: None)

    class FakeBuild:
        executedSteps = []

    step.build = FakeBuild()

    with pytest.raises(RuntimeError):
        step.get_last_step_build_requests()
Exemplo n.º 4
0
def test_get_last_step_build_requests_return_brids():
    step = steps.ReduceTriggerProperties(reducefn=lambda: None)
    trigger = Trigger(waitForFinish=True, schedulerNames=["NA"])
    trigger.brids = object()

    class FakeBuild:
        executedSteps = [trigger, step]

    step.build = FakeBuild()

    assert step.get_last_step_build_requests() is trigger.brids
Exemplo n.º 5
0
def test_get_last_step_build_requests_waitForFinish_must_be_True():
    step = steps.ReduceTriggerProperties(reducefn=lambda: None)

    class FakeBuild:
        executedSteps = [
            Trigger(waitForFinish=False, schedulerNames=["NA"]), step
        ]

    step.build = FakeBuild()

    with pytest.raises(ValueError):
        step.get_last_step_build_requests()
Exemplo n.º 6
0
def test_get_build_properties():
    step = steps.ReduceTriggerProperties(reducefn=lambda: None)
    step.master = Mock()
    step.master.data.get.return_value = object()
    buildid = object()

    returned = step.get_build_properties(buildid)

    step.master.data.get.assert_called_once_with(
        ("builds", buildid, "properties"))

    assert returned is step.master.data.get.return_value
Exemplo n.º 7
0
def test_get_buildrequest_builds():
    step = steps.ReduceTriggerProperties(reducefn=lambda: None)
    step.master = Mock()

    expected = [object(), object(), object()]

    step.master.data.get.return_value = [{"buildid": o} for o in expected]
    buildrequestid = object()

    returned = yield step.get_buildrequest_builds(buildrequestid)

    step.master.data.get.assert_called_once_with(
        ("buildrequests", buildrequestid, "builds"))

    assert returned == expected
Exemplo n.º 8
0
def test_reducefn_not_given():
    with pytest.raises(config.ConfigErrors):
        step = steps.ReduceTriggerProperties()
Exemplo n.º 9
0
def test_reducefn():
    def myreducefn():
        pass

    step = steps.ReduceTriggerProperties(reducefn=myreducefn)
    assert step.reducefn == myreducefn
Exemplo n.º 10
0
def test_defaults():
    step = steps.ReduceTriggerProperties(reducefn=lambda: None)
    assert step.name == 'reducetrigger'
    assert step.haltOnFailure is True
    assert step.flunkOnFailure is True