diff --git a/connect/client/fluent.py b/connect/client/fluent.py index 3e731f8..befacb4 100644 --- a/connect/client/fluent.py +++ b/connect/client/fluent.py @@ -23,7 +23,7 @@ def __init__( self, api_key, endpoint=None, - use_specs=True, + use_specs=False, specs_location=None, validate_using_specs=True, default_headers=None, diff --git a/tests/async_client/test_fluent.py b/tests/async_client/test_fluent.py index b83de7d..396367e 100644 --- a/tests/async_client/test_fluent.py +++ b/tests/async_client/test_fluent.py @@ -13,7 +13,7 @@ async def test_async_get(async_mocker): kwargs = { 'arg1': 'val1', } - c = AsyncConnectClient('API_KEY', use_specs=False) + c = AsyncConnectClient('API_KEY') mocked = async_mocker.AsyncMock() c.execute = mocked await c.get(url, **kwargs) @@ -30,7 +30,7 @@ async def test_create(async_mocker, attr): } kwargs[attr] = {'k1': 'v1'} - c = AsyncConnectClient('API_KEY', use_specs=False) + c = AsyncConnectClient('API_KEY') c.execute = mocked await c.create(url, **kwargs) @@ -53,7 +53,7 @@ async def test_update(async_mocker, attr): } kwargs[attr] = {'k1': 'v1'} - c = AsyncConnectClient('API_KEY', use_specs=False) + c = AsyncConnectClient('API_KEY') c.execute = mocked await c.update(url, **kwargs) @@ -71,7 +71,7 @@ async def test_delete_no_args(async_mocker): mocked = async_mocker.AsyncMock() url = 'https://localhost' - c = AsyncConnectClient('API_KEY', use_specs=False) + c = AsyncConnectClient('API_KEY') c.execute = mocked await c.delete(url) @@ -90,7 +90,7 @@ async def test_delete(async_mocker, attr): } kwargs[attr] = {'k1': 'v1'} - c = AsyncConnectClient('API_KEY', use_specs=False) + c = AsyncConnectClient('API_KEY') c.execute = mocked await c.delete(url, **kwargs) @@ -115,7 +115,6 @@ async def test_execute(httpx_mock): ios = io.StringIO() c = AsyncConnectClient('API_KEY', endpoint='https://localhost', - use_specs=False, logger=RequestLogger(file=ios)) results = await c.execute('get', 'resources') @@ -134,7 +133,7 @@ async def test_execute_validate_with_specs(async_mocker): mocked_specs = async_mocker.MagicMock() mocked_specs.exists.return_value = False - c = AsyncConnectClient('API_KEY', use_specs=False) + c = AsyncConnectClient('API_KEY') c.specs = mocked_specs c._use_specs = True with pytest.raises(ClientError) as cv: @@ -154,7 +153,6 @@ async def test_execute_non_json_response(httpx_mock): c = AsyncConnectClient( 'API_KEY', endpoint='https://localhost', - use_specs=False, ) result = await c.execute('get', 'resources') assert result == b'This is a non json response.' @@ -185,7 +183,6 @@ async def test_execute_retries(httpx_mock): c = AsyncConnectClient( 'API_KEY', endpoint='https://localhost', - use_specs=False, max_retries=2, ) @@ -221,7 +218,6 @@ async def test_execute_max_retries_exceeded(httpx_mock): c = AsyncConnectClient( 'API_KEY', endpoint='https://localhost', - use_specs=False, max_retries=2, ) @@ -240,7 +236,6 @@ async def test_execute_default_headers(httpx_mock): c = AsyncConnectClient( 'API_KEY', endpoint='https://localhost', - use_specs=False, default_headers={'X-Custom-Header': 'custom-header-value'}, ) @@ -262,7 +257,7 @@ async def test_execute_with_kwargs(httpx_mock): status_code=201, ) - c = AsyncConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = AsyncConnectClient('API_KEY', endpoint='https://localhost') kwargs = { 'headers': { 'X-Custom-Header': 'value', @@ -294,7 +289,7 @@ async def test_execute_connect_error(httpx_mock): status_code=400, ) - c = AsyncConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = AsyncConnectClient('API_KEY', endpoint='https://localhost') with pytest.raises(ClientError) as cv: await c.execute('post', 'resources') @@ -318,7 +313,7 @@ async def test_execute_unexpected_connect_error(httpx_mock): status_code=400, ) - c = AsyncConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = AsyncConnectClient('API_KEY', endpoint='https://localhost') with pytest.raises(ClientError) as cv: await c.execute('post', 'resources') @@ -336,7 +331,7 @@ async def test_execute_uparseable_connect_error(httpx_mock): status_code=400, ) - c = AsyncConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = AsyncConnectClient('API_KEY', endpoint='https://localhost') with pytest.raises(ClientError): await c.execute('post', 'resources') @@ -353,7 +348,7 @@ async def test_execute_error_with_reason(httpx_mock, encoding): content='Internal Server Error'.encode(encoding), ) - c = AsyncConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = AsyncConnectClient('API_KEY', endpoint='https://localhost') with pytest.raises(ClientError): await c.execute('post', 'resources') @@ -369,7 +364,7 @@ async def test_execute_delete(httpx_mock): status_code=204, ) - c = AsyncConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = AsyncConnectClient('API_KEY', endpoint='https://localhost') results = await c.execute('delete', 'resources') @@ -377,12 +372,12 @@ async def test_execute_delete(httpx_mock): def test_collection(): - c = AsyncConnectClient('API_KEY', use_specs=False) + c = AsyncConnectClient('API_KEY') assert isinstance(c.collection('resources'), AsyncCollection) def test_ns(): - c = AsyncConnectClient('API_KEY', use_specs=False) + c = AsyncConnectClient('API_KEY') assert isinstance(c.ns('namespace'), AsyncNS) @@ -395,7 +390,7 @@ async def test_execute_with_qs_and_params(httpx_mock): status_code=201, ) - c = AsyncConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = AsyncConnectClient('API_KEY', endpoint='https://localhost') kwargs = { 'params': { 'limit': 100, @@ -415,7 +410,7 @@ async def test_execute_with_params_only(httpx_mock): status_code=201, ) - c = AsyncConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = AsyncConnectClient('API_KEY', endpoint='https://localhost') kwargs = { 'params': { 'limit': 100, diff --git a/tests/client/test_fluent.py b/tests/client/test_fluent.py index a930725..e5263cb 100644 --- a/tests/client/test_fluent.py +++ b/tests/client/test_fluent.py @@ -6,7 +6,6 @@ from requests import RequestException, Timeout -from connect.client.constants import CONNECT_ENDPOINT_URL, CONNECT_SPECS_URL from connect.client.exceptions import ClientError from connect.client.fluent import ConnectClient from connect.client.logger import RequestLogger @@ -16,7 +15,6 @@ def test_default_headers(): c = ConnectClient( 'Api Key', - use_specs=False, default_headers={'X-Custom-Header': 'value'}, ) @@ -27,7 +25,6 @@ def test_default_headers_invalid(): with pytest.raises(ValueError): ConnectClient( 'Api Key', - use_specs=False, default_headers={'Authorization': 'value'}, ) @@ -35,7 +32,6 @@ def test_default_headers_invalid(): def test_default_limit(): c = ConnectClient( 'Api Key', - use_specs=False, default_limit=10, ) @@ -45,37 +41,37 @@ def test_default_limit(): def test_ns(mocker): - c = ConnectClient('Api Key', use_specs=False) + c = ConnectClient('Api Key') assert isinstance(c.ns('namespace'), NS) def test_ns_invalid_type(): - c = ConnectClient('Api Key', use_specs=False) + c = ConnectClient('Api Key') with pytest.raises(TypeError): c.ns(c) def test_ns_invalid_value(): - c = ConnectClient('Api Key', use_specs=False) + c = ConnectClient('Api Key') with pytest.raises(ValueError): c.ns('') def test_collection(mocker): - c = ConnectClient('Api Key', use_specs=False) + c = ConnectClient('Api Key') assert isinstance(c.collection('resources'), Collection) def test_collection_invalid_type(): - c = ConnectClient('Api Key', use_specs=False) + c = ConnectClient('Api Key') with pytest.raises(TypeError): c.collection(c) def test_collection_invalid_value(): - c = ConnectClient('Api Key', use_specs=False) + c = ConnectClient('Api Key') with pytest.raises(ValueError): c.collection('') @@ -87,7 +83,7 @@ def test_get(mocker): 'arg1': 'val1', } - c = ConnectClient('API_KEY', use_specs=False) + c = ConnectClient('API_KEY') c.get(url, **kwargs) @@ -103,7 +99,7 @@ def test_create(mocker, attr): } kwargs[attr] = {'k1': 'v1'} - c = ConnectClient('API_KEY', use_specs=False) + c = ConnectClient('API_KEY') c.create(url, **kwargs) @@ -124,7 +120,7 @@ def test_update(mocker, attr): } kwargs[attr] = {'k1': 'v1'} - c = ConnectClient('API_KEY', use_specs=False) + c = ConnectClient('API_KEY') c.update(url, **kwargs) @@ -140,7 +136,7 @@ def test_delete_no_args(mocker): mocked = mocker.patch.object(ConnectClient, 'execute') url = 'https://localhost' - c = ConnectClient('API_KEY', use_specs=False) + c = ConnectClient('API_KEY') c.delete(url) @@ -157,7 +153,7 @@ def test_delete(mocker, attr): } kwargs[attr] = {'k1': 'v1'} - c = ConnectClient('API_KEY', use_specs=False) + c = ConnectClient('API_KEY') c.delete(url, **kwargs) @@ -180,7 +176,6 @@ def test_execute(mocked_responses): ios = io.StringIO() c = ConnectClient('API_KEY', endpoint='https://localhost', - use_specs=False, logger=RequestLogger(file=ios)) results = c.execute('get', 'resources') @@ -217,7 +212,6 @@ def test_execute_non_json_response(mocked_responses): c = ConnectClient( 'API_KEY', endpoint='https://localhost', - use_specs=False, ) result = c.execute('get', 'resources') assert result == b'This is a non json response.' @@ -256,7 +250,6 @@ def test_execute_retries(mocked_responses, mock_config): c = ConnectClient( 'API_KEY', endpoint='https://localhost', - use_specs=False, max_retries=2, ) @@ -302,7 +295,6 @@ def test_execute_max_retries_exceeded(mocked_responses, mock_config): c = ConnectClient( 'API_KEY', endpoint='https://localhost', - use_specs=False, max_retries=2, ) @@ -320,7 +312,6 @@ def test_execute_default_headers(mocked_responses): c = ConnectClient( 'API_KEY', endpoint='https://localhost', - use_specs=False, default_headers={'X-Custom-Header': 'custom-header-value'}, ) @@ -341,7 +332,7 @@ def test_execute_with_kwargs(mocked_responses): status=201, ) - c = ConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = ConnectClient('API_KEY', endpoint='https://localhost') kwargs = { 'headers': { 'X-Custom-Header': 'value', @@ -365,7 +356,7 @@ def test_execute_with_overwritten_timeout(mocker): side_effect=RequestException(), ) - c = ConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = ConnectClient('API_KEY', endpoint='https://localhost') kwargs = { 'timeout': 500, } @@ -392,7 +383,7 @@ def test_execute_with_default_timeout(mocker): side_effect=RequestException(), ) - c = ConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = ConnectClient('API_KEY', endpoint='https://localhost') with pytest.raises(ClientError): c.execute('post', 'resources') @@ -423,7 +414,7 @@ def test_execute_connect_error(mocked_responses): status=400, ) - c = ConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = ConnectClient('API_KEY', endpoint='https://localhost') with pytest.raises(ClientError) as cv: c.execute('post', 'resources') @@ -446,7 +437,7 @@ def test_execute_unexpected_connect_error(mocked_responses): status=400, ) - c = ConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = ConnectClient('API_KEY', endpoint='https://localhost') with pytest.raises(ClientError) as cv: c.execute('post', 'resources') @@ -463,7 +454,7 @@ def test_execute_uparseable_connect_error(mocked_responses): status=400, ) - c = ConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = ConnectClient('API_KEY', endpoint='https://localhost') with pytest.raises(ClientError): c.execute('post', 'resources') @@ -479,7 +470,7 @@ def test_execute_error_with_reason(mocked_responses, encoding): body='Interñal Server Error'.encode(encoding), ) - c = ConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = ConnectClient('API_KEY', endpoint='https://localhost') with pytest.raises(ClientError): c.execute('post', 'resources') @@ -494,7 +485,7 @@ def test_execute_delete(mocked_responses): status=204, ) - c = ConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = ConnectClient('API_KEY', endpoint='https://localhost') results = c.execute('delete', 'resources') @@ -503,21 +494,19 @@ def test_execute_delete(mocked_responses): def test_create_client_with_defaults(mocker): mocked_specs = mocker.patch('connect.client.fluent.OpenAPISpecs') - - c = ConnectClient('API_KEY') - mocked_specs.assert_called_once_with(CONNECT_SPECS_URL) - assert c.endpoint == CONNECT_ENDPOINT_URL + ConnectClient('API_KEY') + assert mocked_specs.called is False def test_get_attr_with_underscore(mocker): - c = ConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = ConnectClient('API_KEY', endpoint='https://localhost') coll = c.my_collection assert coll.path == 'my-collection' def test_call(mocker): - c = ConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = ConnectClient('API_KEY', endpoint='https://localhost') ns = c('ns') assert isinstance(ns, NS) @@ -526,7 +515,7 @@ def test_call(mocker): def test_print_help(mocker): format_mock = mocker.MagicMock() - c = ConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = ConnectClient('API_KEY', endpoint='https://localhost') c._help_formatter.format = format_mock c.print_help(None) @@ -535,7 +524,7 @@ def test_print_help(mocker): def test_help(mocker): format_mock = mocker.MagicMock() - c = ConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = ConnectClient('API_KEY', endpoint='https://localhost') c._help_formatter.format = format_mock c.help() format_mock.assert_called_once_with(None) @@ -544,7 +533,7 @@ def test_help(mocker): def test_non_server_error(mocker): mocker.patch('connect.client.mixins.requests.request', side_effect=RequestException('generic')) - c = ConnectClient('API_KEY', endpoint='https://localhost', use_specs=False) + c = ConnectClient('API_KEY', endpoint='https://localhost') with pytest.raises(ClientError) as cv: c.execute('get', 'path')