Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use a static time period in test_coops_data_products_w_date_input() #170

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions tests/coops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,8 @@ def test_coops_data_products_default_args(station_id, product):
)


@pytest.fixture
def now_utc():
# Seconds are truncated for COOPS query url
return pd.Timestamp.now("utc").floor("min")


@pytest.mark.parametrize(
"days_before_now, station_id, product",
"days_before_end, station_id, product",
[
(7, 8654467, "water_level"),
(60, 8636580, "hourly_height"),
Expand All @@ -289,9 +283,11 @@ def now_utc():
# (30, 8636580, "daily_mean"),
],
)
def test_coops_data_products_w_date_input(now_utc, days_before_now, station_id, product):
start_date = now_utc - timedelta(days=days_before_now)
end_date = now_utc
def test_coops_data_products_w_date_input(days_before_end, station_id, product):
# 2024-02-05 was the date when the test was added.
# This ensures that the test can continue to run in the future
end_date = pd.Timestamp("2024-02-05", tz="UTC")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmav99 I think at the time I wrote these, there were some limitations on how much back in time the data is available for certain products, so I decided to always use now and then go back a much as data is available, or something close to that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. In that case I think we need to either make the test more lenient e.g. to skip or xfail if the station has no data or use a cassette.

I will close the PR

start_date = end_date - timedelta(days=days_before_end)

df = fetch_coops_station(
station_id,
Expand Down
Loading