コード例 #1
0
def test_run_extension(mocker):
    pkg_resources = mocker.patch('jenkins_epo.bot.pkg_resources')

    from jenkins_epo.bot import Bot

    ep = Mock()
    ep.name = 'ext'
    pkg_resources.iter_entry_points.return_value = [ep]
    ext = ep.resolve.return_value.return_value
    ext.DEFAULTS = {}
    ext.SETTINGS = {}
    ext.run.return_value = []

    bot = Bot()
    assert 'ext' in bot.extensions_map

    pr = Mock(name='pr', payload=dict())
    pr.fetch_commits = CoroutineMock()
    commits = [Mock()]
    pr.repository.process_commits.return_value = commits
    pr.fetch_comments = CoroutineMock(return_value=[])
    commits[0].fetch_statuses = CoroutineMock()

    yield from bot.run(pr)

    assert pr.fetch_commits.mock_calls
    assert pr.fetch_comments.mock_calls
    assert ext.begin.mock_calls
    assert ext.run.mock_calls
コード例 #2
0
ファイル: test_bot.py プロジェクト: peopledoc/jenkins-epo
def test_run_extension(mocker):
    pkg_resources = mocker.patch('jenkins_epo.bot.pkg_resources')

    from jenkins_epo.bot import Bot

    ep = Mock()
    ep.name = 'ext'
    pkg_resources.iter_entry_points.return_value = [ep]
    ext = ep.resolve.return_value.return_value
    ext.DEFAULTS = {}
    ext.SETTINGS = {}
    ext.run.return_value = []

    bot = Bot()
    assert 'ext' in bot.extensions_map

    pr = Mock(name='pr', payload=dict())
    pr.fetch_commits = CoroutineMock()
    commits = [Mock()]
    pr.repository.process_commits.return_value = commits
    pr.fetch_comments = CoroutineMock(return_value=[])
    commits[0].fetch_statuses = CoroutineMock()

    yield from bot.run(pr)

    assert pr.fetch_commits.mock_calls
    assert pr.fetch_comments.mock_calls
    assert ext.begin.mock_calls
    assert ext.run.mock_calls
コード例 #3
0
def test_run_skip_head(mocker):
    pkg_resources = mocker.patch('jenkins_epo.bot.pkg_resources')

    from jenkins_epo.bot import Bot, SkipHead

    ep = Mock()
    ep.name = 'ext'
    pkg_resources.iter_entry_points.return_value = [ep]
    ext = ep.resolve.return_value.return_value
    ext.DEFAULTS = {}
    ext.SETTINGS = {}
    ext.run.side_effect = SkipHead()

    pr = Mock(name='pr', payload=dict())
    pr.fetch_commits = CoroutineMock()
    commits = [Mock()]
    pr.repository.process_commits.return_value = commits
    pr.fetch_comments = CoroutineMock(return_value=[])
    commits[0].fetch_statuses = CoroutineMock()

    yield from Bot().run(pr)

    assert ext.begin.mock_calls
    assert ext.run.mock_calls
コード例 #4
0
ファイル: test_bot.py プロジェクト: peopledoc/jenkins-epo
def test_run_skip_head(mocker):
    pkg_resources = mocker.patch('jenkins_epo.bot.pkg_resources')

    from jenkins_epo.bot import Bot, SkipHead

    ep = Mock()
    ep.name = 'ext'
    pkg_resources.iter_entry_points.return_value = [ep]
    ext = ep.resolve.return_value.return_value
    ext.DEFAULTS = {}
    ext.SETTINGS = {}
    ext.run.side_effect = SkipHead()

    pr = Mock(name='pr', payload=dict())
    pr.fetch_commits = CoroutineMock()
    commits = [Mock()]
    pr.repository.process_commits.return_value = commits
    pr.fetch_comments = CoroutineMock(return_value=[])
    commits[0].fetch_statuses = CoroutineMock()

    yield from Bot().run(pr)

    assert ext.begin.mock_calls
    assert ext.run.mock_calls