コード例 #1
0
def test_request_uninitialised_namespace_then_invalid_query(fetch, url, create_namespace):
    fetch.side_effect = [httpclient.HTTPError(404, 'Not Found'), httpclient.HTTPError(500, 'Internal Server Error')]
    with pytest.raises(httpclient.HTTPError) as exc:
        yield request(None, 'c8ab01', 'pay load')
    assert create_namespace.call_count == 1
    assert fetch.call_count == 2
    assert exc.value.code == 500
コード例 #2
0
def test_request_invalid_query(fetch, url, create_namespace):
    fetch.side_effect = HTTPError(500, 'Internal Server Error')
    with pytest.raises(HTTPError) as exc:
        yield request(None, 'c8ab01', 'pay load')
    assert not create_namespace.called
    assert fetch.call_count == 1
    assert exc.value.status_code == 500
コード例 #3
0
def test_request_invalid_query(fetch, url, create_namespace):
    fetch.side_effect = HTTPError(500, 'Internal Server Error')
    with pytest.raises(HTTPError) as exc:
        yield request(None, 'c8ab01', 'pay load')
    assert not create_namespace.called
    assert fetch.call_count == 1
    assert exc.value.status_code == 500
コード例 #4
0
def test_request_initialise_namespace_http_error(fetch, url, create_namespace, error):
    fetch.side_effect = [httpclient.HTTPError(404, 'Not Found')]
    create_namespace.side_effect = httpclient.HTTPError(500, 'Internal Server Error')
    yield request(None, 'c8ab01', 'pay load')
    assert create_namespace.call_count == 1
    assert fetch.call_count == 2
    assert error.called
コード例 #5
0
def test_request_initialise_namespace_http_conflict(fetch, url, create_namespace, warning):
    fetch.side_effect = [httpclient.HTTPError(404, 'Not Found')]
    create_namespace.side_effect = httpclient.HTTPError(409, 'Namespace already exists')
    yield request(None, 'c8ab01', 'pay load')
    assert create_namespace.call_count == 1
    assert fetch.call_count == 2
    assert warning.called
コード例 #6
0
def test_request_uninitialised_namespace_standalone_mode(options, fetch, url, create_namespace):
    options.standalone = True
    fetch.side_effect = [httpclient.HTTPError(404, 'Not Found')]
    with pytest.raises(httpclient.HTTPError) as exc:
        yield request(None, 'c8ab01', 'pay load')
    assert not create_namespace.called
    assert fetch.call_count == 1
    assert exc.value.code == 404
コード例 #7
0
def test_request_has_content_type(fetch, url):
    yield request('body type',
                  'c8ab01',
                  'pay load',
                  content_type='application/json')
    assert fetch.call_args[1]['headers'] == {
        'Content-Type': 'application/json'
    }
コード例 #8
0
def test_request_uninitialised_namespace_standalone_mode(
        options, fetch, url, create_namespace):
    options.standalone = True
    fetch.side_effect = [httpclient.HTTPError(404, 'Not Found')]
    with pytest.raises(httpclient.HTTPError) as exc:
        yield request(None, 'c8ab01', 'pay load')
    assert not create_namespace.called
    assert fetch.call_count == 1
    assert exc.value.code == 404
コード例 #9
0
def test_request_initialise_namespace_http_conflict(fetch, url,
                                                    create_namespace, warning):
    fetch.side_effect = [httpclient.HTTPError(404, 'Not Found')]
    create_namespace.side_effect = httpclient.HTTPError(
        409, 'Namespace already exists')
    yield request(None, 'c8ab01', 'pay load')
    assert create_namespace.call_count == 1
    assert fetch.call_count == 2
    assert warning.called
コード例 #10
0
def test_request_initialise_namespace_http_error(fetch, url, create_namespace,
                                                 error):
    fetch.side_effect = [httpclient.HTTPError(404, 'Not Found')]
    create_namespace.side_effect = httpclient.HTTPError(
        500, 'Internal Server Error')
    yield request(None, 'c8ab01', 'pay load')
    assert create_namespace.call_count == 1
    assert fetch.call_count == 2
    assert error.called
コード例 #11
0
def test_request_uninitialised_namespace_then_invalid_query(
        fetch, url, create_namespace):
    fetch.side_effect = [
        httpclient.HTTPError(404, 'Not Found'),
        httpclient.HTTPError(500, 'Internal Server Error')
    ]
    with pytest.raises(httpclient.HTTPError) as exc:
        yield request(None, 'c8ab01', 'pay load')
    assert create_namespace.call_count == 1
    assert fetch.call_count == 2
    assert exc.value.code == 500
コード例 #12
0
def test_request_has_content_type_and_response_type(fetch, _set_accept_header,
                                                    url):
    yield request('body type',
                  'c8ab01',
                  'pay load',
                  response_type='csv',
                  content_type='application/json')
    _set_accept_header.assert_called_once_with('csv')
    assert fetch.call_args[1]['headers'] == {
        'Content-Type': 'application/json',
        'Accept': 'text/csv'
    }
コード例 #13
0
def test_request_no_response_type(fetch, url):
    yield request('body type', 'c8ab01', 'pay load')
    assert fetch.call_args[1]['headers'] == {}
コード例 #14
0
def test_request_valid_query(fetch, url):
    result = yield request(None, 'c8ab01', 'pay load')
    assert fetch.call_count == 1
    assert result == 'my response'
コード例 #15
0
def test_request_no_body_type(fetch, url):
    yield request(None, 'c8ab01', 'pay load')
    assert fetch.call_args[1]['body'] == 'pay load'
コード例 #16
0
def test_request_has_body_type(fetch, url):
    yield request('body type', 'c8ab01', 'pay load')
    assert fetch.call_args[1]['body'] == 'body+type=pay+load'
コード例 #17
0
def test_request_has_content_type_and_response_type(fetch, _set_accept_header, url):
    yield request('body type', 'c8ab01', 'pay load', response_type='csv', content_type='application/json')
    _set_accept_header.assert_called_once_with('csv')
    assert fetch.call_args[1]['headers'] == {'Content-Type': 'application/json', 'Accept': 'text/csv'}
コード例 #18
0
def test_request_no_response_type(fetch, url):
    yield request('body type', 'c8ab01', 'pay load')
    assert fetch.call_args[1]['headers'] == {}
コード例 #19
0
def test_request_valid_query(fetch, url):
    result = yield request(None, 'c8ab01', 'pay load')
    assert fetch.call_count == 1
    assert result == 'my response'
コード例 #20
0
def test_request_has_response_type(fetch, _set_accept_header, url):
    yield request('body type', 'c8ab01', 'pay load', response_type='csv')
    _set_accept_header.assert_called_once_with('csv')
    assert fetch.call_args[1]['headers'] == {'Accept': 'text/csv'}
コード例 #21
0
def test_request_no_namespace(url, create_namespace):
    with pytest.raises(httpclient.HTTPError) as exc:
        yield request(None, None, 'pay load')
        assert exc.value.code == 400
        assert exc.value.message == "HTTP 400: Namespace/Repository missing"
コード例 #22
0
def test_request_uninitialised_namespace(fetch, url, create_namespace):
    fetch.side_effect = [httpclient.HTTPError(404, 'Not Found')]
    yield request(None, 'c8ab01', 'pay load')
    assert create_namespace.call_count == 1
    assert fetch.call_count == 2
コード例 #23
0
def test_request_no_namespace(url, create_namespace):
    with pytest.raises(httpclient.HTTPError) as exc:
        yield request(None, None, 'pay load')
        assert exc.value.code == 400
        assert exc.value.message == "HTTP 400: Namespace/Repository missing"
コード例 #24
0
def test_request_has_body_type(fetch, url):
    yield request('body type', 'c8ab01', 'pay load')
    assert fetch.call_args[1]['body'] == 'body+type=pay+load'
コード例 #25
0
def test_request_uninitialised_namespace(fetch, url, create_namespace):
    fetch.side_effect = [httpclient.HTTPError(404, 'Not Found')]
    yield request(None, 'c8ab01', 'pay load')
    assert create_namespace.call_count == 1
    assert fetch.call_count == 2
コード例 #26
0
def test_request_has_content_type(fetch, url):
    yield request('body type', 'c8ab01', 'pay load', content_type='application/json')
    assert fetch.call_args[1]['headers'] == {'Content-Type': 'application/json'}
コード例 #27
0
def test_request_has_response_type(fetch, _set_accept_header, url):
    yield request('body type', 'c8ab01', 'pay load', response_type='csv')
    _set_accept_header.assert_called_once_with('csv')
    assert fetch.call_args[1]['headers'] == {'Accept': 'text/csv'}
コード例 #28
0
def test_request_no_body_type(fetch, url):
    yield request(None, 'c8ab01', 'pay load')
    assert fetch.call_args[1]['body'] == 'pay load'
コード例 #29
0
def test_request_uses_generated_db_url(fetch, url):
    yield request('body type', 'c8ab01', 'pay load')
    assert fetch.call_args[0][0] == 'https://localhost:8000/bigdata/namespace/c8ab01'
コード例 #30
0
def test_request_uses_generated_db_url(fetch, url):
    yield request('body type', 'c8ab01', 'pay load')
    assert fetch.call_args[0][
        0] == 'https://localhost:8000/bigdata/namespace/c8ab01'