diff --git a/.whitesource b/.whitesource index a76605899..9c7ae90b4 100644 --- a/.whitesource +++ b/.whitesource @@ -1,3 +1,14 @@ { - "settingsInheritedFrom": "sede-x/whitesource-config@main" + "scanSettings": { + "baseBranches": [] + }, + "checkRunSettings": { + "vulnerableCheckRunConclusionLevel": "failure", + "displayMode": "diff", + "useMendCheckNames": true + }, + "issueSettings": { + "minSeverityLevel": "LOW", + "issueType": "DEPENDENCY" + } } \ No newline at end of file diff --git a/src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/pjm_historical_load_iso.py b/src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/pjm_historical_load_iso.py index 7905c670f..e4ce5ea5c 100644 --- a/src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/pjm_historical_load_iso.py +++ b/src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/pjm_historical_load_iso.py @@ -14,7 +14,7 @@ import logging import time -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from io import BytesIO import pandas as pd @@ -172,13 +172,17 @@ def _validate_options(self) -> bool: f"Unable to parse End date. Please specify in {self.user_datetime_format} format." ) - if start_date > datetime.utcnow() - timedelta(days=1): + if start_date > datetime.now(timezone.utc).replace(tzinfo=None) - timedelta( + days=1 + ): raise ValueError("Start date can't be in future.") if start_date > end_date: raise ValueError("Start date can't be ahead of End date.") - if end_date > datetime.utcnow() - timedelta(days=1): + if end_date > datetime.now(timezone.utc).replace(tzinfo=None) - timedelta( + days=1 + ): raise ValueError("End date can't be in future.") if self.sleep_duration < 0: diff --git a/src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/pjm_historical_pricing_iso.py b/src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/pjm_historical_pricing_iso.py index d3120e41b..8df0c52f7 100644 --- a/src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/pjm_historical_pricing_iso.py +++ b/src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/pjm_historical_pricing_iso.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from datetime import datetime +from datetime import datetime, timezone import logging import time import pandas as pd @@ -142,13 +142,17 @@ def _validate_options(self) -> bool: f"Unable to parse End date. Please specify in {self.user_datetime_format} format." ) - if start_date > datetime.utcnow() - timedelta(days=1): + if start_date > datetime.now(timezone.utc).replace(tzinfo=None) - timedelta( + days=1 + ): raise ValueError("Start date can't be in future.") if start_date > end_date: raise ValueError("Start date can't be ahead of End date.") - if end_date > datetime.utcnow() - timedelta(days=1): + if end_date > datetime.now(timezone.utc).replace(tzinfo=None) - timedelta( + days=1 + ): raise ValueError("End date can't be in future.") return True diff --git a/src/sdk/python/rtdip_sdk/pipelines/transformers/spark/the_weather_company/raw_forecast_to_weather_data_model.py b/src/sdk/python/rtdip_sdk/pipelines/transformers/spark/the_weather_company/raw_forecast_to_weather_data_model.py index 557f3e5ec..108d2fa0e 100644 --- a/src/sdk/python/rtdip_sdk/pipelines/transformers/spark/the_weather_company/raw_forecast_to_weather_data_model.py +++ b/src/sdk/python/rtdip_sdk/pipelines/transformers/spark/the_weather_company/raw_forecast_to_weather_data_model.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from datetime import datetime +from datetime import datetime, timezone from pyspark.sql import DataFrame, SparkSession from pyspark.sql.functions import when, substring, lit, col, concat @@ -91,7 +91,7 @@ def transform(self) -> DataFrame: self.pre_transform_validation() - processed_date = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") + processed_date = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S") df = ( self.data.withColumn("WeatherDay", substring("FcstValidLocal", 0, 10)) diff --git a/tests/api/v1/test_api_circular_average.py b/tests/api/v1/test_api_circular_average.py index a70869c8b..bc7e01307 100644 --- a/tests/api/v1/test_api_circular_average.py +++ b/tests/api/v1/test_api_circular_average.py @@ -15,7 +15,7 @@ import pytest from pytest_mock import MockerFixture import pandas as pd -from datetime import datetime +from datetime import datetime, timezone from tests.api.v1.api_test_objects import ( CIRCULAR_AVERAGE_MOCKED_PARAMETER_DICT, CIRCULAR_AVERAGE_MOCKED_PARAMETER_ERROR_DICT, @@ -36,7 +36,11 @@ async def test_api_circular_average_get_success(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.5]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.5], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -49,7 +53,8 @@ async def test_api_circular_average_get_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -58,7 +63,11 @@ async def test_api_circular_average_get_success(mocker: MockerFixture): async def test_api_circular_average_get_validation_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -79,7 +88,11 @@ async def test_api_circular_average_get_validation_error(mocker: MockerFixture): async def test_api_circular_average_get_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup( mocker, MOCK_METHOD, test_data, Exception("Error Connecting to Database") @@ -99,7 +112,11 @@ async def test_api_circular_average_get_error(mocker: MockerFixture): async def test_api_circular_average_post_success(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.5]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.5], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -113,7 +130,8 @@ async def test_api_circular_average_post_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -122,7 +140,11 @@ async def test_api_circular_average_post_success(mocker: MockerFixture): async def test_api_circular_average_post_validation_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -144,7 +166,11 @@ async def test_api_circular_average_post_validation_error(mocker: MockerFixture) async def test_api_circular_average_post_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup( mocker, MOCK_METHOD, test_data, Exception("Error Connecting to Database") diff --git a/tests/api/v1/test_api_circular_standard_deviation.py b/tests/api/v1/test_api_circular_standard_deviation.py index 6239620cf..76cf36f54 100644 --- a/tests/api/v1/test_api_circular_standard_deviation.py +++ b/tests/api/v1/test_api_circular_standard_deviation.py @@ -15,7 +15,7 @@ import pytest from pytest_mock import MockerFixture import pandas as pd -from datetime import datetime +from datetime import datetime, timezone from tests.api.v1.api_test_objects import ( CIRCULAR_AVERAGE_MOCKED_PARAMETER_DICT, CIRCULAR_AVERAGE_MOCKED_PARAMETER_ERROR_DICT, @@ -38,7 +38,11 @@ async def test_api_circular_standard_deviation_get_success(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.5]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.5], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -51,7 +55,8 @@ async def test_api_circular_standard_deviation_get_success(mocker: MockerFixture actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -62,7 +67,11 @@ async def test_api_circular_standard_deviation_get_validation_error( mocker: MockerFixture, ): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -83,7 +92,11 @@ async def test_api_circular_standard_deviation_get_validation_error( async def test_api_circular_standard_deviation_get_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup( mocker, MOCK_METHOD, test_data, Exception("Error Connecting to Database") @@ -103,7 +116,11 @@ async def test_api_circular_standard_deviation_get_error(mocker: MockerFixture): async def test_api_circular_standard_deviation_post_success(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.5]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.5], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -117,7 +134,8 @@ async def test_api_circular_standard_deviation_post_success(mocker: MockerFixtur actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -128,7 +146,11 @@ async def test_api_circular_standard_deviation_post_validation_error( mocker: MockerFixture, ): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -150,7 +172,11 @@ async def test_api_circular_standard_deviation_post_validation_error( async def test_api_circular_standard_deviation_post_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup( mocker, MOCK_METHOD, test_data, Exception("Error Connecting to Database") diff --git a/tests/api/v1/test_api_interpolate.py b/tests/api/v1/test_api_interpolate.py index 850a7b80f..ddde12b35 100644 --- a/tests/api/v1/test_api_interpolate.py +++ b/tests/api/v1/test_api_interpolate.py @@ -15,7 +15,7 @@ import pytest from pytest_mock import MockerFixture import pandas as pd -from datetime import datetime +from datetime import datetime, timezone from tests.api.v1.api_test_objects import ( INTERPOLATE_MOCKED_PARAMETER_DICT, INTERPOLATE_MOCKED_PARAMETER_ERROR_DICT, @@ -36,7 +36,11 @@ async def test_api_interpolate_get_success(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -49,7 +53,8 @@ async def test_api_interpolate_get_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -58,7 +63,11 @@ async def test_api_interpolate_get_success(mocker: MockerFixture): async def test_api_interpolate_get_validation_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -79,7 +88,11 @@ async def test_api_interpolate_get_validation_error(mocker: MockerFixture): async def test_api_interpolate_get_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup( mocker, MOCK_METHOD, test_data, Exception("Error Connecting to Database") @@ -99,7 +112,11 @@ async def test_api_interpolate_get_error(mocker: MockerFixture): async def test_api_interpolate_post_success(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -113,7 +130,8 @@ async def test_api_interpolate_post_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -122,7 +140,11 @@ async def test_api_interpolate_post_success(mocker: MockerFixture): async def test_api_interpolate_post_validation_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -144,7 +166,11 @@ async def test_api_interpolate_post_validation_error(mocker: MockerFixture): async def test_api_interpolate_post_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup( mocker, MOCK_METHOD, test_data, Exception("Error Connecting to Database") diff --git a/tests/api/v1/test_api_interpolation_at_time.py b/tests/api/v1/test_api_interpolation_at_time.py index bfb7646f7..40f99f72d 100644 --- a/tests/api/v1/test_api_interpolation_at_time.py +++ b/tests/api/v1/test_api_interpolation_at_time.py @@ -15,7 +15,7 @@ import pytest from pytest_mock import MockerFixture import pandas as pd -from datetime import datetime +from datetime import datetime, timezone from tests.api.v1.api_test_objects import ( INTERPOLATION_AT_TIME_MOCKED_PARAMETER_DICT, INTERPOLATION_AT_TIME_POST_MOCKED_PARAMETER_DICT, @@ -35,7 +35,11 @@ async def test_api_interpolation_at_time_get_success(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -48,7 +52,8 @@ async def test_api_interpolation_at_time_get_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -58,7 +63,7 @@ async def test_api_interpolation_at_time_get_success(mocker: MockerFixture): # TODO: Readd this test when this github issue is resolved https://github.com/tiangolo/fastapi/issues/9920 # async def test_api_interpolation_at_time_get_validation_error(mocker: MockerFixture): # test_data = pd.DataFrame( -# {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} +# {"EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Value": [1.01]} # ) # mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -79,7 +84,11 @@ async def test_api_interpolation_at_time_get_success(mocker: MockerFixture): async def test_api_interpolation_at_time_get_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup( mocker, MOCK_METHOD, test_data, Exception("Error Connecting to Database") @@ -99,7 +108,11 @@ async def test_api_interpolation_at_time_get_error(mocker: MockerFixture): async def test_api_interpolation_at_time_post_success(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -113,7 +126,8 @@ async def test_api_interpolation_at_time_post_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -123,7 +137,7 @@ async def test_api_interpolation_at_time_post_success(mocker: MockerFixture): # TODO: Readd this test when this github issue is resolved https://github.com/tiangolo/fastapi/issues/9920 # async def test_api_interpolation_at_time_post_validation_error(mocker: MockerFixture): # test_data = pd.DataFrame( -# {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} +# {"EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Value": [1.01]} # ) # mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -145,7 +159,11 @@ async def test_api_interpolation_at_time_post_success(mocker: MockerFixture): async def test_api_interpolation_at_time_post_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup( mocker, MOCK_METHOD, test_data, Exception("Error Connecting to Database") diff --git a/tests/api/v1/test_api_latest.py b/tests/api/v1/test_api_latest.py index e591676cc..0a9bb6958 100644 --- a/tests/api/v1/test_api_latest.py +++ b/tests/api/v1/test_api_latest.py @@ -15,7 +15,7 @@ import pytest from pytest_mock import MockerFixture import pandas as pd -from datetime import datetime +from datetime import datetime, timezone from tests.api.v1.api_test_objects import ( METADATA_MOCKED_PARAMETER_DICT, METADATA_MOCKED_PARAMETER_ERROR_DICT, @@ -38,11 +38,11 @@ async def test_api_latest_get_tags_provided_success(mocker: MockerFixture): test_data = pd.DataFrame( { "TagName": ["TestTag"], - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "Status": ["Good"], "Value": ["1.01"], "ValueType": ["string"], - "GoodEventTime": [datetime.utcnow()], + "GoodEventTime": [datetime.now(timezone.utc)], "GoodValue": ["1.01"], "GoodValueType": ["string"], } @@ -57,7 +57,8 @@ async def test_api_latest_get_tags_provided_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -70,7 +71,7 @@ async def test_api_latest_get_no_good_values_tags_provided_success( test_data = pd.DataFrame( { "TagName": ["TestTag"], - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "Status": ["Good"], "Value": ["1.01"], "ValueType": ["string"], @@ -89,7 +90,8 @@ async def test_api_latest_get_no_good_values_tags_provided_success( actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -100,11 +102,11 @@ async def test_api_latest_get_no_tags_provided_success(mocker: MockerFixture): test_data = pd.DataFrame( { "TagName": ["TestTag"], - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "Status": ["Good"], "Value": ["1.01"], "ValueType": ["string"], - "GoodEventTime": [datetime.utcnow()], + "GoodEventTime": [datetime.now(timezone.utc)], "GoodValue": ["1.01"], "GoodValueType": ["string"], } @@ -123,7 +125,8 @@ async def test_api_latest_get_no_tags_provided_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -134,11 +137,11 @@ async def test_api_latest_get_validation_error(mocker: MockerFixture): test_data = pd.DataFrame( { "TagName": ["TestTag"], - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "Status": ["Good"], "Value": ["1.01"], "ValueType": ["string"], - "GoodEventTime": [datetime.utcnow()], + "GoodEventTime": [datetime.now(timezone.utc)], "GoodValue": ["1.01"], "GoodValueType": ["string"], } @@ -165,11 +168,11 @@ async def test_api_latest_get_error(mocker: MockerFixture): test_data = pd.DataFrame( { "TagName": ["TestTag"], - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "Status": ["Good"], "Value": ["1.01"], "ValueType": ["string"], - "GoodEventTime": [datetime.utcnow()], + "GoodEventTime": [datetime.now(timezone.utc)], "GoodValue": ["1.01"], "GoodValueType": ["string"], } @@ -193,11 +196,11 @@ async def test_api_latest_post_tags_provided_success(mocker: MockerFixture): test_data = pd.DataFrame( { "TagName": ["TestTag"], - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "Status": ["Good"], "Value": ["1.01"], "ValueType": ["string"], - "GoodEventTime": [datetime.utcnow()], + "GoodEventTime": [datetime.now(timezone.utc)], "GoodValue": ["1.01"], "GoodValueType": ["string"], } @@ -215,7 +218,8 @@ async def test_api_latest_post_tags_provided_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -226,11 +230,11 @@ async def test_api_latest_post_no_tags_provided_error(mocker: MockerFixture): test_data = pd.DataFrame( { "TagName": ["TestTag"], - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "Status": ["Good"], "Value": ["1.01"], "ValueType": ["string"], - "GoodEventTime": [datetime.utcnow()], + "GoodEventTime": [datetime.now(timezone.utc)], "GoodValue": ["1.01"], "GoodValueType": ["string"], } @@ -259,11 +263,11 @@ async def test_api_latest_post_validation_error(mocker: MockerFixture): test_data = pd.DataFrame( { "TagName": ["TestTag"], - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "Status": ["Good"], "Value": ["1.01"], "ValueType": ["string"], - "GoodEventTime": [datetime.utcnow()], + "GoodEventTime": [datetime.now(timezone.utc)], "GoodValue": ["1.01"], "GoodValueType": ["string"], } @@ -291,11 +295,11 @@ async def test_api_raw_post_error(mocker: MockerFixture): test_data = pd.DataFrame( { "TagName": ["TestTag"], - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "Status": ["Good"], "Value": ["1.01"], "ValueType": ["string"], - "GoodEventTime": [datetime.utcnow()], + "GoodEventTime": [datetime.now(timezone.utc)], "GoodValue": ["1.01"], "GoodValueType": ["string"], } diff --git a/tests/api/v1/test_api_metadata.py b/tests/api/v1/test_api_metadata.py index 577d65095..ca6d7dd35 100644 --- a/tests/api/v1/test_api_metadata.py +++ b/tests/api/v1/test_api_metadata.py @@ -46,7 +46,8 @@ async def test_api_metadata_get_tags_provided_success(mocker: MockerFixture): actual = response.text expected = TEST_DATA.to_json(orient="table", index=False) expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -67,7 +68,8 @@ async def test_api_metadata_get_no_tags_provided_success(mocker: MockerFixture): actual = response.text expected = TEST_DATA.to_json(orient="table", index=False) expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -120,7 +122,8 @@ async def test_api_metadata_post_tags_provided_success(mocker: MockerFixture): actual = response.text expected = TEST_DATA.to_json(orient="table", index=False) expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 diff --git a/tests/api/v1/test_api_plot.py b/tests/api/v1/test_api_plot.py index ea2f9b7a6..f2058f20d 100644 --- a/tests/api/v1/test_api_plot.py +++ b/tests/api/v1/test_api_plot.py @@ -15,7 +15,7 @@ import pytest from pytest_mock import MockerFixture import pandas as pd -from datetime import datetime +from datetime import datetime, timezone from tests.api.v1.api_test_objects import ( PLOT_MOCKED_PARAMETER_DICT, PLOT_MOCKED_PARAMETER_ERROR_DICT, @@ -37,7 +37,7 @@ async def test_api_plot_get_success(mocker: MockerFixture): test_data = pd.DataFrame( { - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Average": [1.01], "Min": [1.01], @@ -56,7 +56,8 @@ async def test_api_plot_get_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -66,7 +67,7 @@ async def test_api_plot_get_success(mocker: MockerFixture): async def test_api_plot_get_validation_error(mocker: MockerFixture): test_data = pd.DataFrame( { - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Average": [1.01], "Min": [1.01], @@ -96,7 +97,7 @@ async def test_api_plot_get_validation_error(mocker: MockerFixture): async def test_api_pot_get_error(mocker: MockerFixture): test_data = pd.DataFrame( { - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Average": [1.01], "Min": [1.01], @@ -123,7 +124,7 @@ async def test_api_pot_get_error(mocker: MockerFixture): async def test_api_plot_post_success(mocker: MockerFixture): test_data = pd.DataFrame( { - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Average": [1.01], "Min": [1.01], @@ -145,7 +146,8 @@ async def test_api_plot_post_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -155,7 +157,7 @@ async def test_api_plot_post_success(mocker: MockerFixture): async def test_api_plot_post_validation_error(mocker: MockerFixture): test_data = pd.DataFrame( { - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Average": [1.01], "Min": [1.01], @@ -186,7 +188,7 @@ async def test_api_plot_post_validation_error(mocker: MockerFixture): async def test_api_plot_post_error(mocker: MockerFixture): test_data = pd.DataFrame( { - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Average": [1.01], "Min": [1.01], diff --git a/tests/api/v1/test_api_raw.py b/tests/api/v1/test_api_raw.py index 51edebaec..c0e910801 100644 --- a/tests/api/v1/test_api_raw.py +++ b/tests/api/v1/test_api_raw.py @@ -16,7 +16,7 @@ from pytest_mock import MockerFixture import pandas as pd import numpy as np -from datetime import datetime +from datetime import datetime, timezone from tests.api.v1.api_test_objects import ( RAW_MOCKED_PARAMETER_DICT, RAW_MOCKED_PARAMETER_ERROR_DICT, @@ -42,7 +42,7 @@ async def test_api_raw_get_success(mocker: MockerFixture): test_data = pd.DataFrame( { - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Status": ["Good"], "Value": [1.01], @@ -57,7 +57,8 @@ async def test_api_raw_get_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -67,7 +68,7 @@ async def test_api_raw_get_success(mocker: MockerFixture): async def test_api_raw_get_validation_error(mocker: MockerFixture): test_data = pd.DataFrame( { - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Status": ["Good"], "Value": [1.01], @@ -91,7 +92,7 @@ async def test_api_raw_get_validation_error(mocker: MockerFixture): async def test_api_raw_get_error(mocker: MockerFixture): test_data = pd.DataFrame( { - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Status": ["Good"], "Value": [1.01], @@ -114,7 +115,7 @@ async def test_api_raw_get_error(mocker: MockerFixture): async def test_api_raw_post_success(mocker: MockerFixture): test_data = pd.DataFrame( { - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Status": ["Good"], "Value": [1.01], @@ -132,7 +133,8 @@ async def test_api_raw_post_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -142,7 +144,7 @@ async def test_api_raw_post_success(mocker: MockerFixture): async def test_api_raw_post_validation_error(mocker: MockerFixture): test_data = pd.DataFrame( { - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Status": ["Good"], "Value": [1.01], @@ -169,7 +171,7 @@ async def test_api_raw_post_validation_error(mocker: MockerFixture): async def test_api_raw_post_error(mocker: MockerFixture): test_data = pd.DataFrame( { - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Status": ["Good"], "Value": [1.01], diff --git a/tests/api/v1/test_api_resample.py b/tests/api/v1/test_api_resample.py index f5fafbc39..fb37a287e 100644 --- a/tests/api/v1/test_api_resample.py +++ b/tests/api/v1/test_api_resample.py @@ -15,7 +15,7 @@ import pytest from pytest_mock import MockerFixture import pandas as pd -from datetime import datetime +from datetime import datetime, timezone from tests.api.v1.api_test_objects import ( RESAMPLE_MOCKED_PARAMETER_DICT, RESAMPLE_MOCKED_PARAMETER_ERROR_DICT, @@ -36,7 +36,11 @@ async def test_api_resample_get_success(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -47,7 +51,8 @@ async def test_api_resample_get_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -56,7 +61,11 @@ async def test_api_resample_get_success(mocker: MockerFixture): async def test_api_resample_get_validation_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -77,7 +86,11 @@ async def test_api_resample_get_validation_error(mocker: MockerFixture): async def test_api_resample_get_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup( mocker, MOCK_METHOD, test_data, Exception("Error Connecting to Database") @@ -95,7 +108,11 @@ async def test_api_resample_get_error(mocker: MockerFixture): async def test_api_resample_post_success(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -109,7 +126,8 @@ async def test_api_resample_post_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -118,7 +136,11 @@ async def test_api_resample_post_success(mocker: MockerFixture): async def test_api_resample_post_validation_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -140,7 +162,11 @@ async def test_api_resample_post_validation_error(mocker: MockerFixture): async def test_api_resample_post_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup( mocker, MOCK_METHOD, test_data, Exception("Error Connecting to Database") diff --git a/tests/api/v1/test_api_sql.py b/tests/api/v1/test_api_sql.py index 685136773..4e0a1aaa9 100644 --- a/tests/api/v1/test_api_sql.py +++ b/tests/api/v1/test_api_sql.py @@ -16,7 +16,7 @@ from pytest_mock import MockerFixture import pandas as pd import numpy as np -from datetime import datetime +from datetime import datetime, timezone from tests.api.v1.api_test_objects import ( SQL_POST_MOCKED_PARAMETER_DICT, SQL_POST_BODY_MOCKED_PARAMETER_DICT, @@ -37,7 +37,7 @@ async def test_api_raw_post_success(mocker: MockerFixture): test_data = pd.DataFrame( { - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Status": ["Good"], "Value": [1.01], @@ -55,7 +55,8 @@ async def test_api_raw_post_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":100,"offset":100,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":100,"offset":100,"next":null}}' ) assert response.status_code == 200 @@ -65,7 +66,7 @@ async def test_api_raw_post_success(mocker: MockerFixture): async def test_api_raw_post_validation_error(mocker: MockerFixture): test_data = pd.DataFrame( { - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Status": ["Good"], "Value": [1.01], @@ -92,7 +93,7 @@ async def test_api_raw_post_validation_error(mocker: MockerFixture): async def test_api_raw_post_error(mocker: MockerFixture): test_data = pd.DataFrame( { - "EventTime": [datetime.utcnow()], + "EventTime": [datetime.now(timezone.utc)], "TagName": ["TestTag"], "Status": ["Good"], "Value": [1.01], diff --git a/tests/api/v1/test_api_summary.py b/tests/api/v1/test_api_summary.py index a731b31bf..813d29c55 100644 --- a/tests/api/v1/test_api_summary.py +++ b/tests/api/v1/test_api_summary.py @@ -57,7 +57,8 @@ async def test_api_summary_get_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -110,7 +111,8 @@ async def test_api_summary_post_success(mocker: MockerFixture): actual = response.text expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 diff --git a/tests/api/v1/test_api_time_weighted_average.py b/tests/api/v1/test_api_time_weighted_average.py index 01a9a6e8c..64280f9da 100644 --- a/tests/api/v1/test_api_time_weighted_average.py +++ b/tests/api/v1/test_api_time_weighted_average.py @@ -15,7 +15,7 @@ import pytest from pytest_mock import MockerFixture import pandas as pd -from datetime import datetime +from datetime import datetime, timezone from tests.api.v1.api_test_objects import ( TIME_WEIGHTED_AVERAGE_MOCKED_PARAMETER_DICT, TIME_WEIGHTED_AVERAGE_MOCKED_PARAMETER_ERROR_DICT, @@ -36,7 +36,11 @@ async def test_api_time_weighted_average_get_success(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) test_data = test_data.set_index("EventTime") mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -51,7 +55,8 @@ async def test_api_time_weighted_average_get_success(mocker: MockerFixture): test_data = test_data.reset_index() expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -60,7 +65,11 @@ async def test_api_time_weighted_average_get_success(mocker: MockerFixture): async def test_api_time_weighted_average_get_validation_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -81,7 +90,11 @@ async def test_api_time_weighted_average_get_validation_error(mocker: MockerFixt async def test_api_time_weighted_average_get_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup( mocker, MOCK_METHOD, test_data, Exception("Error Connecting to Database") @@ -101,7 +114,11 @@ async def test_api_time_weighted_average_get_error(mocker: MockerFixture): async def test_api_time_weighted_average_post_success(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) test_data = test_data.set_index("EventTime") mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -117,7 +134,8 @@ async def test_api_time_weighted_average_post_success(mocker: MockerFixture): test_data = test_data.reset_index() expected = test_data.to_json(orient="table", index=False, date_unit="ns") expected = ( - expected.rstrip("}") + ',"pagination":{"limit":null,"offset":null,"next":null}}' + expected.replace(',"tz":"UTC"', "").rstrip("}") + + ',"pagination":{"limit":null,"offset":null,"next":null}}' ) assert response.status_code == 200 @@ -126,7 +144,11 @@ async def test_api_time_weighted_average_post_success(mocker: MockerFixture): async def test_api_time_weighted_average_post_validation_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup(mocker, MOCK_METHOD, test_data) @@ -148,7 +170,11 @@ async def test_api_time_weighted_average_post_validation_error(mocker: MockerFix async def test_api_time_weighted_average_post_error(mocker: MockerFixture): test_data = pd.DataFrame( - {"EventTime": [datetime.utcnow()], "TagName": ["TestTag"], "Value": [1.01]} + { + "EventTime": [datetime.now(timezone.utc)], + "TagName": ["TestTag"], + "Value": [1.01], + } ) mocker = mocker_setup( mocker, MOCK_METHOD, test_data, Exception("Error Connecting to Database") diff --git a/tests/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/test_miso_daily_load_iso.py b/tests/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/test_miso_daily_load_iso.py index bce27e670..372be5827 100644 --- a/tests/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/test_miso_daily_load_iso.py +++ b/tests/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/test_miso_daily_load_iso.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone import sys from io import StringIO @@ -147,7 +147,7 @@ def test_miso_daily_load_iso_invalid_date_format(spark_session: SparkSession): def test_miso_daily_load_iso_invalid_date(spark_session: SparkSession): - future_date = (datetime.utcnow() + timedelta(days=10)).strftime("%Y%m%d") + future_date = (datetime.now(timezone.utc) + timedelta(days=10)).strftime("%Y%m%d") with pytest.raises(ValueError) as exc_info: iso_source = MISODailyLoadISOSource( diff --git a/tests/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/test_miso_historical_load_iso.py b/tests/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/test_miso_historical_load_iso.py index 649180595..a4b9e6b84 100644 --- a/tests/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/test_miso_historical_load_iso.py +++ b/tests/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/test_miso_historical_load_iso.py @@ -13,7 +13,7 @@ # limitations under the License. from io import StringIO -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone import pandas as pd import pytest @@ -156,7 +156,7 @@ def test_miso_historical_load_iso_invalid_dates(spark_session: SparkSession): assert str(exc_info.value) == "Start date can't be ahead of End date." - future_date = (datetime.utcnow() + timedelta(days=10)).strftime("%Y%m%d") + future_date = (datetime.now(timezone.utc) + timedelta(days=10)).strftime("%Y%m%d") with pytest.raises(ValueError) as exc_info: iso_source = MISOHistoricalLoadISOSource( diff --git a/tests/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/test_pjm_historical_load_iso.py b/tests/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/test_pjm_historical_load_iso.py index f78b1df23..296a8c735 100644 --- a/tests/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/test_pjm_historical_load_iso.py +++ b/tests/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/test_pjm_historical_load_iso.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone import sys from io import StringIO @@ -141,7 +141,7 @@ def test_miso_historical_load_iso_invalid_dates(spark_session: SparkSession): assert str(exc_info.value) == "Start date can't be ahead of End date." - future_date = (datetime.utcnow() + timedelta(days=10)).strftime("%Y-%m-%d") + future_date = (datetime.now(timezone.utc) + timedelta(days=10)).strftime("%Y-%m-%d") with pytest.raises(ValueError) as exc_info: iso_source = PJMHistoricalLoadISOSource( diff --git a/tests/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/test_pjm_historical_pricing_iso.py b/tests/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/test_pjm_historical_pricing_iso.py index b278257f9..372e1ed50 100644 --- a/tests/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/test_pjm_historical_pricing_iso.py +++ b/tests/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/test_pjm_historical_pricing_iso.py @@ -14,7 +14,7 @@ import io import json import sys -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from io import StringIO import numpy as np @@ -368,7 +368,7 @@ def test_miso_historical_pricing_iso_invalid_dates(spark_session: SparkSession): assert str(exc_info.value) == "Start date can't be ahead of End date." - future_date = (datetime.utcnow() + timedelta(days=10)).strftime("%Y-%m-%d") + future_date = (datetime.now(timezone.utc) + timedelta(days=10)).strftime("%Y-%m-%d") with pytest.raises(ValueError) as exc_info: iso_source = PJMHistoricalPricingISOSource(