예제 #1
0
def test_full_consume_post_failed(mock_session):
    mock_session.post.return_value.raise_for_status.side_effect = \
        requests.exceptions.HTTPError()
    fake_msg = get_fake_msg('message')

    with pytest.raises(requests.exceptions.HTTPError):
        consumer._consume_helper(create_message(fake_msg))
예제 #2
0
def test_publisher_id(mock_session, consume_fn):
    mock_session.get.return_value.json.return_value = {'data': []}

    fake_msg = get_fake_msg('jmsx_user_id')
    consume_fn(create_message(fake_msg))
    # Verify the post URL
    assert mock_session.post.call_args_list[0][0][0] == \
        'https://resultsdb.domain.local/api/v2.0/results'

    actual_data = json.loads(
        mock_session.post.call_args_list[0][1]['data'])
    assert 'msg-example-ci' == actual_data['data'].get('publisher_id'), actual_data
예제 #3
0
def test_full_consume_post_timeout(mock_session):
    mock_session.post.side_effect = requests.exceptions.Timeout()
    fake_msg = get_fake_msg('message')

    with pytest.raises(requests.exceptions.Timeout):
        consumer._consume_helper(create_message(fake_msg))