diff --git a/geomagio/api/ws/DataApiQuery.py b/geomagio/api/ws/DataApiQuery.py index d8ec41d878f5081810fefe07094c7b0440b693eb..ac88e6092a94967b8d2a3907936b88fd776c6545 100644 --- a/geomagio/api/ws/DataApiQuery.py +++ b/geomagio/api/ws/DataApiQuery.py @@ -74,7 +74,9 @@ class DataApiQuery(BaseModel): data_host: Union[DataHost, str] = DataHost.DEFAULT @field_validator("starttime", mode="before") - def validate_starttime(cls, starttime: CustomUTCDateTimeType) -> CustomUTCDateTimeType: + def validate_starttime( + cls, starttime: CustomUTCDateTimeType + ) -> CustomUTCDateTimeType: if not starttime: return default_starttime() else: diff --git a/test/DataApiQuery_test.py b/test/DataApiQuery_test.py index a74479952cde90bb1859a3f1aa50c593c2322375..117f1758c1be5f4d9668dc25208ec8fcee5a3596 100644 --- a/test/DataApiQuery_test.py +++ b/test/DataApiQuery_test.py @@ -29,6 +29,7 @@ def test_DataApiQuery_defaults(): # assumes the env var DATA_HOST is not set assert_equal(query.data_host.value, "edgecwb.usgs.gov") + def test_DataApiQuery_starttime_is_none(): query = DataApiQuery(id="BOU", starttime=None) @@ -46,6 +47,7 @@ def test_DataApiQuery_starttime_is_none(): # assumes the env var DATA_HOST is not set assert_equal(query.data_host.value, "edgecwb.usgs.gov") + def test_DataApiQuery_valid(): query = DataApiQuery( id="DED", @@ -125,6 +127,7 @@ def test_DataApiQuery_default_only_endtime(): assert_equal(query.format, OutputFormat.IAGA2002) assert_equal(query.data_host, DataHost.DEFAULT) + def test_DataApiQuery_default_only_invalid_endtime(): # test an invalid endtime that is before default starttime query = None @@ -133,7 +136,7 @@ def test_DataApiQuery_default_only_invalid_endtime(): except Exception as e: err = e.errors() assert "Value error, Starttime must be before endtime." == err[0]["msg"] - + assert_equal(query, None) diff --git a/test/api_test/ws_test/data_test.py b/test/api_test/ws_test/data_test.py index 93debfd214dbed52addacf18f3b545a44b8ad64c..3376e31100056e7186ce47543fad8f81d352e404 100644 --- a/test/api_test/ws_test/data_test.py +++ b/test/api_test/ws_test/data_test.py @@ -39,11 +39,10 @@ def test_get_data_query(test_client): assert_equal(query.format, "iaga2002") assert_equal(query.data_type, "R1") + def test_get_data_query_no_starttime(test_client): """test.api_test.ws_test.data_test.test_get_data_query_no_starttime()""" - response = test_client.get( - "/query/?id=BOU&elements=X,Y,Z,F" - ) + response = test_client.get("/query/?id=BOU&elements=X,Y,Z,F") query = DataApiQuery(**response.json()) assert_equal(query.id, "BOU") @@ -55,6 +54,7 @@ def test_get_data_query_no_starttime(test_client): # expect endtime to default to 1 day after starttiime assert_equal(query.endtime, expected + (86400 - 0.001)) + async def test_get_data_query_extra_params(test_client): with pytest.raises(ValueError) as error: response = await test_client.get( diff --git a/test/api_test/ws_test/filter_test.py b/test/api_test/ws_test/filter_test.py index 23dd507039097f1eb3324716710649bd9caebd98..dbd2964ea2072d8dd678ae745fe60a5f37c54f64 100644 --- a/test/api_test/ws_test/filter_test.py +++ b/test/api_test/ws_test/filter_test.py @@ -40,9 +40,7 @@ def test_get_filter_data_query(test_client): def test_get_filter_data_query_no_starttime(test_client): """test.api_test.ws_test.data_test.test_get_filter_data_query_no_starttime()""" - response = test_client.get( - "/filter/?id=BOU&elements=X,Y,Z,F" - ) + response = test_client.get("/filter/?id=BOU&elements=X,Y,Z,F") query = FilterApiQuery(**response.json()) assert_equal(query.id, "BOU") diff --git a/test/pydantic_utcdatetime_test.py b/test/pydantic_utcdatetime_test.py index 87f15aa44e43a6e643577afd6c3d5f39c3663cb9..232cd7b1cd6e58ecbe5b91e4eeb53efc87f900b7 100644 --- a/test/pydantic_utcdatetime_test.py +++ b/test/pydantic_utcdatetime_test.py @@ -16,6 +16,7 @@ def test_UTCDateTime_string(): assert_equal(t.starttime, UTCDateTime(2024, 11, 5, 0, 0)) + def test_UTCDateTime_ISO860_string(): # `ISO8601:2004`_ string from obspy docs t = TimeClass(starttime="2024-11-05T00:00:00.00") @@ -48,6 +49,9 @@ def test_invalid(): except Exception as e: err = e.errors() assert "Input should be an instance of UTCDateTime" == err[0]["msg"] - assert "Value error, Invalid time type. See obspy UTCDateTime for more information." == err[1]["msg"] + assert ( + "Value error, Invalid time type. See obspy UTCDateTime for more information." + == err[1]["msg"] + ) assert_equal(t, None)