Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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'
    }
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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'
    }
Esempio n. 13
0
def test_request_no_response_type(fetch, url):
    yield request('body type', 'c8ab01', 'pay load')
    assert fetch.call_args[1]['headers'] == {}
Esempio n. 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'
Esempio n. 15
0
def test_request_no_body_type(fetch, url):
    yield request(None, 'c8ab01', 'pay load')
    assert fetch.call_args[1]['body'] == 'pay load'
Esempio n. 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'
Esempio n. 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'}
Esempio n. 18
0
def test_request_no_response_type(fetch, url):
    yield request('body type', 'c8ab01', 'pay load')
    assert fetch.call_args[1]['headers'] == {}
Esempio n. 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'
Esempio n. 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'}
Esempio n. 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"
Esempio n. 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
Esempio n. 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"
Esempio n. 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'
Esempio n. 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
Esempio n. 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'}
Esempio n. 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'}
Esempio n. 28
0
def test_request_no_body_type(fetch, url):
    yield request(None, 'c8ab01', 'pay load')
    assert fetch.call_args[1]['body'] == 'pay load'
Esempio n. 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'
Esempio n. 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'