Beispiel #1
0
def test_wait_on_exit():
    exit_status = 3
    mock_container = mock.Mock(
        spec=Container,
        name='cname',
        wait=mock.Mock(return_value=exit_status))

    expected = '{} exited with code {}\n'.format(mock_container.name, exit_status)
    assert expected == wait_on_exit(mock_container)
Beispiel #2
0
def test_wait_on_exit():
    exit_status = 3
    mock_container = mock.Mock(spec=Container,
                               name='cname',
                               wait=mock.Mock(return_value=exit_status))

    expected = '{} exited with code {}\n'.format(mock_container.name,
                                                 exit_status)
    assert expected == wait_on_exit(mock_container)
Beispiel #3
0
def test_wait_on_exit_raises():
    status_code = 500

    def mock_wait():
        resp = requests.Response()
        resp.status_code = status_code
        raise APIError("Bad server", resp)

    mock_container = mock.Mock(spec=Container, name="cname", wait=mock_wait)

    expected = "Unexpected API error for {} (HTTP code {})\n".format(mock_container.name, status_code)
    assert expected in wait_on_exit(mock_container)
Beispiel #4
0
def test_wait_on_exit_raises():
    status_code = 500

    def mock_wait():
        resp = requests.Response()
        resp.status_code = status_code
        raise APIError('Bad server', resp)

    mock_container = mock.Mock(spec=Container, name='cname', wait=mock_wait)

    expected = 'Unexpected API error for {} (HTTP code {})\n'.format(
        mock_container.name,
        status_code,
    )
    assert expected in wait_on_exit(mock_container)