From da8b2e035b952338761a2f83f56e8e8e421c3208 Mon Sep 17 00:00:00 2001 From: Alexandra Hobbs <ahobbs@contractor.usgs.gov> Date: Thu, 19 Dec 2024 10:42:41 -0700 Subject: [PATCH] linted --- geomagio/api/ws/DataApiQuery.py | 4 +++- test/DataApiQuery_test.py | 5 ++++- test/api_test/ws_test/data_test.py | 6 +++--- test/api_test/ws_test/filter_test.py | 4 +--- test/pydantic_utcdatetime_test.py | 6 +++++- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/geomagio/api/ws/DataApiQuery.py b/geomagio/api/ws/DataApiQuery.py index d8ec41d8..ac88e609 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 a7447995..117f1758 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 93debfd2..3376e311 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 23dd5070..dbd2964e 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 87f15aa4..232cd7b1 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) -- GitLab