Esempio n. 1
0
def test_paasta_rollback_mark_for_deployment_wrong_cluster(
    mock_mark_for_deployment,
    mock_get_git_url,
    mock_list_clusters,
    mock_figure_out_service_name,
    mock_validate_given_instances,
    mock_list_all_instances_for_service,
):

    fake_args = Mock(
        cluster='cluster1',
        instances='instance1',
        commit='123456'
    )

    mock_get_git_url.return_value = 'git://git.repo'
    mock_figure_out_service_name.return_value = 'fakeservice'
    mock_list_clusters.return_value = ['cluster0', 'cluster2']
    mock_list_all_instances_for_service.return_value = ['instance1', 'instance2']
    mock_validate_given_instances.return_value = [['instance1'], []]

    with raises(SystemExit) as sys_exit:
        paasta_rollback(fake_args)
        assert sys_exit.value_code == 1

    assert mock_mark_for_deployment.call_count == 0
Esempio n. 2
0
def test_paasta_rollback_mark_for_deployment_multiple_instance_args(
    mock_mark_for_deployment,
    mock_get_git_url,
    mock_list_clusters,
    mock_figure_out_service_name,
    mock_validate_given_instances,
    mock_list_all_instances_for_service,
):

    fake_args = Mock(
        cluster='cluster1',
        instances='instance1,instance2',
        commit='123456'
    )

    mock_get_git_url.return_value = 'git://git.repo'
    mock_figure_out_service_name.return_value = 'fakeservice'
    mock_list_clusters.return_value = ['cluster1', 'cluster2']
    mock_list_all_instances_for_service.return_value = ['instance1', 'instance2', 'instance3']
    mock_validate_given_instances.return_value = [['instance1', 'instance2'], []]

    with raises(SystemExit) as sys_exit:
        paasta_rollback(fake_args)
        assert sys_exit.value_code == 0

    expected = [
        call(
            git_url=mock_get_git_url.return_value,
            cluster=fake_args.cluster,
            service=mock_figure_out_service_name.return_value,
            commit=fake_args.commit,
            instance='instance1'
        ),
        call(
            git_url=mock_get_git_url.return_value,
            cluster=fake_args.cluster,
            service=mock_figure_out_service_name.return_value,
            commit=fake_args.commit,
            instance='instance2'
        ),
    ]

    mock_mark_for_deployment.assert_has_calls(expected, any_order=True)
    assert mock_mark_for_deployment.call_count == 2