Beispiel #1
0
def test_queuer(mocker, WORKERS):
    mocker.patch('jenkins_epo.tasks.WORKERS', WORKERS)
    from jenkins_epo.tasks import QueuerTask

    pr = Mock()
    pr.sort_key.return_value = (80, )

    repo = Mock()
    repo.fetch_protected_branches = CoroutineMock()
    repo.process_protected_branches.return_value = []
    repo.fetch_pull_requests = CoroutineMock()
    repo.process_pull_requests.return_value = [pr]

    task = QueuerTask(repo, Mock())

    yield from task()

    assert str(task)
    assert WORKERS.enqueue.mock_calls
    assert task.task_factory.mock_calls
    assert repo.fetch_protected_branches.mock_calls
    assert repo.fetch_pull_requests.mock_calls