From afcb5bb5330b4627432d3d32ba9ba1ce259566a3 Mon Sep 17 00:00:00 2001 From: Austin Raney Date: Wed, 16 Jun 2021 17:14:52 -0400 Subject: [PATCH] add nwis_test to check DeprecationWarning raised --- python/nwis_client/tests/test_nwis.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/python/nwis_client/tests/test_nwis.py b/python/nwis_client/tests/test_nwis.py index b54b65be..1c1ebfc1 100644 --- a/python/nwis_client/tests/test_nwis.py +++ b/python/nwis_client/tests/test_nwis.py @@ -178,10 +178,6 @@ def mock_json(*args, **kwargs): (datetime(2020, 8, 10), "2020-08-10T00:00+0000"), (np.datetime64("2020-08-10"), "2020-08-10T00:00+0000"), (pd.to_datetime("2020-08-10"), "2020-08-10T00:00+0000"), - # Non green light test - ("2020-08-10T04:15-05:00", "2020-08-10T09:15+0000"), - # Strange behavior here in #6. np converts dt string w/ tzinfo to UTC by default - (pd.to_datetime("2020-08-10T04:15-05:00"), "2020-08-10T09:15+0000"), ] @@ -191,6 +187,19 @@ def test_handle_dates(setup_iv, test, validation): date = setup_iv._handle_date(test) assert date == validation +test_get_startDT_endDT_scenarios_should_warn = [ + # Non green light test + ("2020-08-10T04:15-05:00", "2020-08-10T09:15+0000"), + # Strange behavior here in #6. np converts dt string w/ tzinfo to UTC by default + (pd.to_datetime("2020-08-10T04:15-05:00"), "2020-08-10T09:15+0000"), +] + +@pytest.mark.parametrize("test,validation", test_get_startDT_endDT_scenarios_should_warn) +def test_handle_dates_raise_deprecation_warning(setup_iv, test, validation): + """ Input dates should be output as strings in UTC tz """ + with pytest.warns(DeprecationWarning): + date = setup_iv._handle_date(test) + assert date == validation test_get_startDT_endDT_scenarios_as_list = [ (["2020-01-01", "2020-02-01"], ["2020-01-01T00:00+0000", "2020-02-01T00:00+0000"]),