コード例 #1
0
def test_generate_pipeline_run_fails(
        mock_run,
        mock_get_team_email_address,
):
    mock_get_team_email_address.return_value = 'fake_email'
    mock_run.return_value = (1, 'Big bad wolf')
    with raises(SystemExit) as sys_exit:
        generate_pipeline('fake_service')
    assert sys_exit.value.code == 1
コード例 #2
0
def test_generate_pipeline_calls_the_right_commands_and_owner(
        mock_get_git_repo_for_fab_repo,
        mock_get_team_email_address,
        mock_run,
):
    mock_run.return_value = (0, 'Everything OK')
    mock_get_team_email_address.return_value = '*****@*****.**'
    mock_get_git_repo_for_fab_repo.return_value = 'fake_repo'
    generate_pipeline('fake_service')
    assert mock_run.call_count == 2
    expected_cmd1 = ('fab_repo setup_jenkins:services/fake_service,profile=paasta_boilerplate,'
                     'owner=fake_email,repo=fake_repo')
    mock_run.assert_any_call(expected_cmd1, timeout=90)
    expected_cmd2 = ('fab_repo setup_jenkins:services/fake_service,profile=paasta,'
                     'job_disabled=False,owner=fake_email,repo=fake_repo')
    mock_run.assert_any_call(expected_cmd2, timeout=90)
コード例 #3
0
def test_generate_pipeline_success(
        mock_run,
        mock_get_team_email_address,
):
    mock_get_team_email_address.return_value = 'fake_email'
    mock_run.return_value = (0, 'Everything OK')
    assert generate_pipeline('fake_service') is None
コード例 #4
0
def test_generate_pipeline_uses_team_name_as_fallback_for_owner(
        mock_get_git_repo_for_fab_repo,
        mock_get_team,
        mock_get_team_email_address,
        mock_run,
):
    mock_run.return_value = (0, 'Everything OK')
    mock_get_team_email_address.return_value = None
    mock_get_team.return_value = "fake_team"
    mock_get_git_repo_for_fab_repo.return_value = 'fake_repo'
    generate_pipeline('fake_service')
    assert mock_run.call_count == 2
    expected_cmd1 = ('fab_repo setup_jenkins:services/fake_service,profile=paasta_boilerplate,'
                     'owner=fake_team,repo=fake_repo')
    mock_run.assert_any_call(expected_cmd1, timeout=90)
    expected_cmd2 = ('fab_repo setup_jenkins:services/fake_service,profile=paasta,'
                     'job_disabled=False,owner=fake_team,repo=fake_repo')
    mock_run.assert_any_call(expected_cmd2, timeout=90)