diff --git a/src/sdk/python/rtdip_sdk/pipelines/data_quality/data_manipulation/spark/interval_filtering.py b/src/sdk/python/rtdip_sdk/pipelines/data_quality/data_manipulation/spark/interval_filtering.py index 644ca6232..8641b7c14 100644 --- a/src/sdk/python/rtdip_sdk/pipelines/data_quality/data_manipulation/spark/interval_filtering.py +++ b/src/sdk/python/rtdip_sdk/pipelines/data_quality/data_manipulation/spark/interval_filtering.py @@ -85,7 +85,6 @@ def filter(self) -> DataFrame: tolerance_in_ms = None if self.tolerance is not None: tolerance_in_ms = self.get_time_delta(self.tolerance).total_seconds() * 1000 - print(tolerance_in_ms) time_delta_in_ms = self.get_time_delta(self.interval).total_seconds() * 1000 diff --git a/tests/api/v1/test_api_batch.py b/tests/api/v1/test_api_batch.py index 3b6076396..2878d3607 100644 --- a/tests/api/v1/test_api_batch.py +++ b/tests/api/v1/test_api_batch.py @@ -38,7 +38,7 @@ RawResponse, ) from pandas.io.json import build_table_schema -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport, ASGITransport from src.api.v1 import app from src.api.v1.common import json_response_batch from src.sdk.python.rtdip_sdk.queries.time_series import batch @@ -87,7 +87,7 @@ async def test_api_batch_single_get_success(mocker: MockerFixture): mock_lookup = "src.api.v1.batch.lookup_before_get" mocked_lookup_before_get = mocker.patch(mock_lookup, return_value=None) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -175,7 +175,7 @@ async def test_api_batch_single_get_success_with_lookup(mocker: MockerFixture): mock_lookup = "src.api.v1.batch.lookup_before_get" mocked_lookup_before_get = mocker.patch(mock_lookup, return_value=test_data) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -255,7 +255,7 @@ async def test_api_batch_single_post_success(mocker: MockerFixture): # Make a surveillance batch method reference to check if called and what args with surveillance_batch = mocker.patch(mock_method, return_value=mock_method_return_data) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -300,7 +300,7 @@ async def test_api_batch_single_get_unsupported_route_error(mocker: MockerFixtur os.environ, {"DATABRICKS_SERVING_ENDPOINT": MOCK_MAPPING_ENDPOINT_URL} ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -343,7 +343,7 @@ async def test_api_batch_single_post_missing_body_error(mocker: MockerFixture): os.environ, {"DATABRICKS_SERVING_ENDPOINT": MOCK_MAPPING_ENDPOINT_URL} ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -406,7 +406,7 @@ async def test_api_batch_multiple_success(mocker: MockerFixture): # Make a surveillance batch method reference to check if called and what args with surveillance_batch = mocker.patch(mock_method, side_effect=mock_patch_side_effect) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -464,7 +464,7 @@ async def test_api_batch_one_success_one_fail(mocker: MockerFixture): os.environ, {"DATABRICKS_SERVING_ENDPOINT": MOCK_MAPPING_ENDPOINT_URL} ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -515,7 +515,7 @@ async def test_api_batch_one_success_one_fail(mocker: MockerFixture): os.environ, {"DATABRICKS_SERVING_ENDPOINT": MOCK_MAPPING_ENDPOINT_URL} ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, diff --git a/tests/api/v1/test_api_circular_average.py b/tests/api/v1/test_api_circular_average.py index 99100c52f..ec09d55c1 100644 --- a/tests/api/v1/test_api_circular_average.py +++ b/tests/api/v1/test_api_circular_average.py @@ -15,6 +15,7 @@ import os import pytest +from fastapi import FastAPI from pytest_mock import MockerFixture import pandas as pd from datetime import datetime, timezone @@ -30,7 +31,7 @@ MOCK_TAG_MAPPING_EMPTY, MOCK_MAPPING_ENDPOINT_URL, ) -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport, ASGITransport from src.api.v1 import app MOCK_METHOD = "src.sdk.python.rtdip_sdk.queries.time_series.circular_average.get" @@ -42,7 +43,7 @@ async def test_api_circular_average_get_success(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -59,7 +60,7 @@ async def test_api_circular_average_get_validation_error( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -82,7 +83,7 @@ async def test_api_circular_average_get_error(mocker: MockerFixture, api_test_da Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -97,7 +98,7 @@ async def test_api_circular_average_get_error(mocker: MockerFixture, api_test_da async def test_api_circular_average_post_success(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -115,7 +116,7 @@ async def test_api_circular_average_post_validation_error( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -139,7 +140,7 @@ async def test_api_circular_average_post_error(mocker: MockerFixture, api_test_d Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -182,7 +183,7 @@ async def test_api_circular_average_get_lookup_success(mocker: MockerFixture): modified_param_dict = CIRCULAR_AVERAGE_MOCKED_PARAMETER_DICT.copy() del modified_param_dict["business_unit"] - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=modified_param_dict ) @@ -228,7 +229,7 @@ async def test_api_circular_average_post_lookup_success(mocker: MockerFixture): modified_param_dict = CIRCULAR_AVERAGE_MOCKED_PARAMETER_DICT.copy() del modified_param_dict["business_unit"] - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -278,7 +279,7 @@ async def test_api_circular_average_get_lookup_no_tag_map_error(mocker: MockerFi modified_param_dict["tagname"] = ["NonExistentTag"] del modified_param_dict["business_unit"] - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=modified_param_dict ) diff --git a/tests/api/v1/test_api_circular_standard_deviation.py b/tests/api/v1/test_api_circular_standard_deviation.py index 8db08ce19..7b944a362 100644 --- a/tests/api/v1/test_api_circular_standard_deviation.py +++ b/tests/api/v1/test_api_circular_standard_deviation.py @@ -25,7 +25,7 @@ TEST_HEADERS, BASE_URL, ) -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport from src.api.v1 import app MOCK_METHOD = ( @@ -41,7 +41,7 @@ async def test_api_circular_standard_deviation_get_success( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -58,7 +58,7 @@ async def test_api_circular_standard_deviation_get_validation_error( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -83,7 +83,7 @@ async def test_api_circular_standard_deviation_get_error( Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -100,7 +100,7 @@ async def test_api_circular_standard_deviation_post_success( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -118,7 +118,7 @@ async def test_api_circular_standard_deviation_post_validation_error( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -144,7 +144,7 @@ async def test_api_circular_standard_deviation_post_error( Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, diff --git a/tests/api/v1/test_api_interpolate.py b/tests/api/v1/test_api_interpolate.py index 80f67ba6b..0cc96fc34 100644 --- a/tests/api/v1/test_api_interpolate.py +++ b/tests/api/v1/test_api_interpolate.py @@ -25,7 +25,7 @@ TEST_HEADERS, BASE_URL, ) -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport, ASGITransport from src.api.v1 import app MOCK_METHOD = "src.sdk.python.rtdip_sdk.queries.time_series.interpolate.get" @@ -37,7 +37,7 @@ async def test_api_interpolate_get_success(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -54,7 +54,7 @@ async def test_api_interpolate_get_validation_error( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -77,7 +77,7 @@ async def test_api_interpolate_get_error(mocker: MockerFixture, api_test_data): Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -92,7 +92,7 @@ async def test_api_interpolate_get_error(mocker: MockerFixture, api_test_data): async def test_api_interpolate_post_success(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -110,7 +110,7 @@ async def test_api_interpolate_post_validation_error( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -134,7 +134,7 @@ async def test_api_interpolate_post_error(mocker: MockerFixture, api_test_data): Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, diff --git a/tests/api/v1/test_api_interpolation_at_time.py b/tests/api/v1/test_api_interpolation_at_time.py index 23218d5f4..bb7c49d09 100644 --- a/tests/api/v1/test_api_interpolation_at_time.py +++ b/tests/api/v1/test_api_interpolation_at_time.py @@ -24,7 +24,7 @@ TEST_HEADERS, BASE_URL, ) -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport from src.api.v1 import app MOCK_METHOD = "src.sdk.python.rtdip_sdk.queries.time_series.interpolation_at_time.get" @@ -38,7 +38,7 @@ async def test_api_interpolation_at_time_get_success( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -57,7 +57,7 @@ async def test_api_interpolation_at_time_get_success( # ) # mocker = mocker_setup(mocker, MOCK_METHOD, test_data) -# async with AsyncClient(app=app, base_url=BASE_URL) as ac: +# async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: # response = await ac.get( # MOCK_API_NAME, # headers=TEST_HEADERS, @@ -82,7 +82,7 @@ async def test_api_interpolation_at_time_get_error( Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -99,7 +99,7 @@ async def test_api_interpolation_at_time_post_success( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -119,7 +119,7 @@ async def test_api_interpolation_at_time_post_success( # ) # mocker = mocker_setup(mocker, MOCK_METHOD, test_data) -# async with AsyncClient(app=app, base_url=BASE_URL) as ac: +# async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: # response = await ac.post( # MOCK_API_NAME, # headers=TEST_HEADERS, @@ -145,7 +145,7 @@ async def test_api_interpolation_at_time_post_error( Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, diff --git a/tests/api/v1/test_api_latest.py b/tests/api/v1/test_api_latest.py index 1bc3b29a3..c89e4571d 100644 --- a/tests/api/v1/test_api_latest.py +++ b/tests/api/v1/test_api_latest.py @@ -29,7 +29,7 @@ MOCK_TAG_MAPPING_EMPTY, MOCK_MAPPING_ENDPOINT_URL, ) -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport from src.api.v1 import app MOCK_METHOD = "src.sdk.python.rtdip_sdk.queries.time_series.latest.get" @@ -43,7 +43,7 @@ async def test_api_latest_get_tags_provided_success( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_latest"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=METADATA_MOCKED_PARAMETER_DICT ) @@ -58,7 +58,7 @@ async def test_api_latest_get_no_good_values_tags_provided_success( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_latest"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=METADATA_MOCKED_PARAMETER_DICT ) @@ -75,7 +75,7 @@ async def test_api_latest_get_no_tags_provided_success( METADATA_MOCKED_PARAMETER_NO_TAG_DICT = METADATA_MOCKED_PARAMETER_DICT.copy() METADATA_MOCKED_PARAMETER_NO_TAG_DICT.pop("tag_name") - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -90,7 +90,7 @@ async def test_api_latest_get_no_tags_provided_success( async def test_api_latest_get_validation_error(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_latest"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -113,7 +113,7 @@ async def test_api_latest_get_error(mocker: MockerFixture, api_test_data): Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=METADATA_MOCKED_PARAMETER_DICT ) @@ -128,7 +128,7 @@ async def test_api_latest_post_tags_provided_success( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_latest"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -148,7 +148,7 @@ async def test_api_latest_post_no_tags_provided_error( METADATA_MOCKED_PARAMETER_NO_TAG_DICT = METADATA_MOCKED_PARAMETER_DICT.copy() METADATA_MOCKED_PARAMETER_NO_TAG_DICT.pop("tag_name") - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -166,7 +166,7 @@ async def test_api_latest_post_no_tags_provided_error( async def test_api_latest_post_validation_error(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_latest"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -190,7 +190,7 @@ async def test_api_raw_post_error(mocker: MockerFixture, api_test_data): Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -238,7 +238,7 @@ async def test_api_latest_get_lookup_success(mocker: MockerFixture): modified_param_dict = METADATA_MOCKED_PARAMETER_DICT.copy() del modified_param_dict["business_unit"] - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=modified_param_dict ) @@ -288,7 +288,7 @@ async def test_api_latest_post_lookup_success(mocker: MockerFixture): modified_param_dict = METADATA_MOCKED_PARAMETER_DICT.copy() del modified_param_dict["business_unit"] - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -342,7 +342,7 @@ async def test_api_latest_get_lookup_no_tag_map_error(mocker: MockerFixture): modified_param_dict["tagname"] = ["NonExistentTag"] del modified_param_dict["business_unit"] - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=modified_param_dict ) diff --git a/tests/api/v1/test_api_metadata.py b/tests/api/v1/test_api_metadata.py index 966014ecb..afcf39a9a 100644 --- a/tests/api/v1/test_api_metadata.py +++ b/tests/api/v1/test_api_metadata.py @@ -28,7 +28,7 @@ MOCK_TAG_MAPPING_EMPTY, MOCK_MAPPING_ENDPOINT_URL, ) -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport from src.api.v1 import app MOCK_METHOD = "src.sdk.python.rtdip_sdk.queries.metadata.get" @@ -45,7 +45,7 @@ async def test_api_metadata_get_tags_provided_success( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_metadata"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=METADATA_MOCKED_PARAMETER_DICT ) @@ -62,7 +62,7 @@ async def test_api_metadata_get_no_tags_provided_success( METADATA_MOCKED_PARAMETER_NO_TAG_DICT = METADATA_MOCKED_PARAMETER_DICT.copy() METADATA_MOCKED_PARAMETER_NO_TAG_DICT.pop("tag_name") - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -77,7 +77,7 @@ async def test_api_metadata_get_no_tags_provided_success( async def test_api_metadata_get_validation_error(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_metadata"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -100,7 +100,7 @@ async def test_api_metadata_get_error(mocker: MockerFixture, api_test_data): Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=METADATA_MOCKED_PARAMETER_DICT ) @@ -115,7 +115,7 @@ async def test_api_metadata_post_tags_provided_success( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_metadata"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -135,7 +135,7 @@ async def test_api_metadata_post_no_tags_provided_error( METADATA_MOCKED_PARAMETER_NO_TAG_DICT = METADATA_MOCKED_PARAMETER_DICT.copy() METADATA_MOCKED_PARAMETER_NO_TAG_DICT.pop("tag_name") - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -153,7 +153,7 @@ async def test_api_metadata_post_no_tags_provided_error( async def test_api_metadata_post_validation_error(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_metadata"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -177,7 +177,7 @@ async def test_api_metadata_post_error(mocker: MockerFixture, api_test_data): Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -212,7 +212,7 @@ async def test_api_metadata_get_lookup_success(mocker: MockerFixture): modified_param_dict = METADATA_MOCKED_PARAMETER_DICT.copy() del modified_param_dict["business_unit"] - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=modified_param_dict ) @@ -249,7 +249,7 @@ async def test_api_metadata_post_lookup_success(mocker: MockerFixture): modified_param_dict = METADATA_MOCKED_PARAMETER_DICT.copy() del modified_param_dict["business_unit"] - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -290,7 +290,7 @@ async def test_api_metadata_get_lookup_no_tag_map_error(mocker: MockerFixture): modified_param_dict["tagname"] = ["NonExistentTag"] del modified_param_dict["business_unit"] - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=modified_param_dict ) diff --git a/tests/api/v1/test_api_plot.py b/tests/api/v1/test_api_plot.py index 52560e293..f86e103e7 100644 --- a/tests/api/v1/test_api_plot.py +++ b/tests/api/v1/test_api_plot.py @@ -25,7 +25,7 @@ TEST_HEADERS, BASE_URL, ) -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport from src.api.v1 import app MOCK_METHOD = "src.sdk.python.rtdip_sdk.queries.time_series.plot.get" @@ -37,7 +37,7 @@ async def test_api_plot_get_success(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_plot"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=PLOT_MOCKED_PARAMETER_DICT ) @@ -50,7 +50,7 @@ async def test_api_plot_get_success(mocker: MockerFixture, api_test_data): async def test_api_plot_get_validation_error(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_plot"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -73,7 +73,7 @@ async def test_api_pot_get_error(mocker: MockerFixture, api_test_data): Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=PLOT_MOCKED_PARAMETER_DICT ) @@ -86,7 +86,7 @@ async def test_api_pot_get_error(mocker: MockerFixture, api_test_data): async def test_api_plot_post_success(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_plot"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -102,7 +102,7 @@ async def test_api_plot_post_success(mocker: MockerFixture, api_test_data): async def test_api_plot_post_validation_error(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_plot"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -126,7 +126,7 @@ async def test_api_plot_post_error(mocker: MockerFixture, api_test_data): Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, diff --git a/tests/api/v1/test_api_raw.py b/tests/api/v1/test_api_raw.py index afde6d60b..539439edf 100644 --- a/tests/api/v1/test_api_raw.py +++ b/tests/api/v1/test_api_raw.py @@ -29,7 +29,7 @@ ) from pandas.io.json import build_table_schema import pandas as pd -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport from src.api.v1 import app MOCK_METHOD = "src.sdk.python.rtdip_sdk.queries.time_series.raw.get" @@ -41,7 +41,7 @@ async def test_api_raw_get_success(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_raw"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=RAW_MOCKED_PARAMETER_DICT ) @@ -54,7 +54,7 @@ async def test_api_raw_get_success(mocker: MockerFixture, api_test_data): async def test_api_raw_get_validation_error(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_raw"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=RAW_MOCKED_PARAMETER_ERROR_DICT ) @@ -75,7 +75,7 @@ async def test_api_raw_get_error(mocker: MockerFixture, api_test_data): Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=RAW_MOCKED_PARAMETER_DICT ) @@ -88,7 +88,7 @@ async def test_api_raw_get_error(mocker: MockerFixture, api_test_data): async def test_api_raw_post_success(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_raw"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -104,7 +104,7 @@ async def test_api_raw_post_success(mocker: MockerFixture, api_test_data): async def test_api_raw_post_validation_error(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_raw"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -128,7 +128,7 @@ async def test_api_raw_post_error(mocker: MockerFixture, api_test_data): Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -172,7 +172,7 @@ async def test_api_raw_get_lookup_success(mocker: MockerFixture, api_test_data): modified_param_dict = RAW_MOCKED_PARAMETER_DICT.copy() del modified_param_dict["business_unit"] - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=modified_param_dict ) @@ -217,7 +217,7 @@ async def test_api_raw_post_lookup_success(mocker: MockerFixture): modified_param_dict = RAW_POST_MOCKED_PARAMETER_DICT.copy() del modified_param_dict["business_unit"] - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -267,7 +267,7 @@ async def test_api_raw_get_lookup_no_tag_map_error(mocker: MockerFixture): modified_param_dict["tagname"] = ["NonExistentTag"] del modified_param_dict["business_unit"] - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: actual = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=modified_param_dict ) diff --git a/tests/api/v1/test_api_resample.py b/tests/api/v1/test_api_resample.py index 2baa5a6fc..59d62814d 100644 --- a/tests/api/v1/test_api_resample.py +++ b/tests/api/v1/test_api_resample.py @@ -25,7 +25,7 @@ TEST_HEADERS, BASE_URL, ) -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport from src.api.v1 import app MOCK_METHOD = "src.sdk.python.rtdip_sdk.queries.time_series.resample.get" @@ -37,7 +37,7 @@ async def test_api_resample_get_success(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=RESAMPLE_MOCKED_PARAMETER_DICT ) @@ -50,7 +50,7 @@ async def test_api_resample_get_success(mocker: MockerFixture, api_test_data): async def test_api_resample_get_validation_error(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -73,7 +73,7 @@ async def test_api_resample_get_error(mocker: MockerFixture, api_test_data): Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=RESAMPLE_MOCKED_PARAMETER_DICT ) @@ -86,7 +86,7 @@ async def test_api_resample_get_error(mocker: MockerFixture, api_test_data): async def test_api_resample_post_success(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -102,7 +102,7 @@ async def test_api_resample_post_success(mocker: MockerFixture, api_test_data): async def test_api_resample_post_validation_error(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -126,7 +126,7 @@ async def test_api_resample_post_error(mocker: MockerFixture, api_test_data): Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, diff --git a/tests/api/v1/test_api_sql.py b/tests/api/v1/test_api_sql.py index 1ea88482e..cecc98de4 100644 --- a/tests/api/v1/test_api_sql.py +++ b/tests/api/v1/test_api_sql.py @@ -25,7 +25,7 @@ BASE_URL, ) from pandas.io.json import build_table_schema -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport from src.api.v1 import app MOCK_METHOD = "src.sdk.python.rtdip_sdk.queries.sql.sql_query.SQLQueryBuilder.get" @@ -37,7 +37,7 @@ async def test_api_sql_post_success(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_raw"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -53,7 +53,7 @@ async def test_api_sql_post_success(mocker: MockerFixture, api_test_data): async def test_api_sql_post_validation_error(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_raw"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -77,7 +77,7 @@ async def test_api_sql_post_error(mocker: MockerFixture, api_test_data): Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, diff --git a/tests/api/v1/test_api_summary.py b/tests/api/v1/test_api_summary.py index 88c2f1cbe..5ffa1290b 100644 --- a/tests/api/v1/test_api_summary.py +++ b/tests/api/v1/test_api_summary.py @@ -24,7 +24,7 @@ TEST_HEADERS, BASE_URL, ) -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport from src.api.v1 import app import json @@ -37,7 +37,7 @@ async def test_api_summary_get_success(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_summary"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=SUMMARY_MOCKED_PARAMETER_DICT ) @@ -50,7 +50,7 @@ async def test_api_summary_get_success(mocker: MockerFixture, api_test_data): async def test_api_summary_get_validation_error(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_summary"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -73,7 +73,7 @@ async def test_api_summary_get_error(mocker: MockerFixture, api_test_data): Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, params=SUMMARY_MOCKED_PARAMETER_DICT ) @@ -86,7 +86,7 @@ async def test_api_summary_get_error(mocker: MockerFixture, api_test_data): async def test_api_summary_post_success(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_summary"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -102,7 +102,7 @@ async def test_api_summary_post_success(mocker: MockerFixture, api_test_data): async def test_api_summary_post_validation_error(mocker: MockerFixture, api_test_data): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_summary"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -126,7 +126,7 @@ async def test_api_summary_post_error(mocker: MockerFixture, api_test_data): Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, diff --git a/tests/api/v1/test_api_time_weighted_average.py b/tests/api/v1/test_api_time_weighted_average.py index 99eb19c8d..e0018f71a 100644 --- a/tests/api/v1/test_api_time_weighted_average.py +++ b/tests/api/v1/test_api_time_weighted_average.py @@ -25,7 +25,7 @@ TEST_HEADERS, BASE_URL, ) -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport from src.api.v1 import app MOCK_METHOD = "src.sdk.python.rtdip_sdk.queries.time_series.time_weighted_average.get" @@ -39,7 +39,7 @@ async def test_api_time_weighted_average_get_success( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -56,7 +56,7 @@ async def test_api_time_weighted_average_get_validation_error( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -81,7 +81,7 @@ async def test_api_time_weighted_average_get_error( Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get( MOCK_API_NAME, headers=TEST_HEADERS, @@ -98,7 +98,7 @@ async def test_api_time_weighted_average_post_success( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -116,7 +116,7 @@ async def test_api_time_weighted_average_post_validation_error( ): mocker = mocker_setup(mocker, MOCK_METHOD, api_test_data["mock_data_agg"]) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, @@ -142,7 +142,7 @@ async def test_api_time_weighted_average_post_error( Exception("Error Connecting to Database"), ) - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.post( MOCK_API_NAME, headers=TEST_HEADERS, diff --git a/tests/api/v1/test_api_utilities.py b/tests/api/v1/test_api_utilities.py index fb3042a6b..dfa4c4d42 100644 --- a/tests/api/v1/test_api_utilities.py +++ b/tests/api/v1/test_api_utilities.py @@ -14,7 +14,7 @@ import pytest from pytest_mock import MockerFixture -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport from tests.api.v1.api_test_objects import BASE_URL from src.api.v1 import app @@ -22,7 +22,7 @@ async def test_api_home(mocker: MockerFixture): - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get("/") assert response.status_code == 307 @@ -30,14 +30,14 @@ async def test_api_home(mocker: MockerFixture): async def test_api_docs(mocker: MockerFixture): - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get("/docs") assert response.status_code == 200 async def test_api_redoc(mocker: MockerFixture): - async with AsyncClient(app=app, base_url=BASE_URL) as ac: + async with AsyncClient(transport=ASGITransport(app), base_url=BASE_URL) as ac: response = await ac.get("/redoc") assert response.status_code == 200