def test_build_steps_only_fails_commits_present_when_the_step_was_started(self):
        step, commit1, commit2, callback = BuildStep("step1"), MockCommit("1"), MockCommit("2"), Mock()
        step.add_failure_listener(callback)

        step.add_commit(commit1)
        step.start()
        step.add_commit(commit2)
        step.fail()

        callback.assert_called_once_with([commit1])
    def test_build_step_failures_call_failure_callbacks(self):
        step, commit1, commit2, callback = BuildStep("step1"), MockCommit("1"), MockCommit("2"), Mock()
        step.add_failure_listener(callback)

        step.add_commit(commit1)
        step.add_commit(commit2)
        step.start()
        step.fail()

        callback.assert_called_once_with([commit1, commit2])
    def test_build_step_doesnt_call_wrong_callbacks(self):
        step = BuildStep("step1")
        commit1, commit2 = MockCommit("1"), MockCommit("2")
        success_callback, failure_callback = Mock(), Mock()
        step.add_success_listener(success_callback)
        step.add_failure_listener(failure_callback)

        step.add_commit(commit1)
        step.start()
        step.fail()

        step.add_commit(commit2)
        step.start()
        step.succeed()

        failure_callback.assert_called_once_with([commit1])
        success_callback.assert_called_once_with([commit2])