|
| 1 | +import datetime as dt |
| 2 | + |
1 | 3 | import pandas as pd |
2 | 4 | import pytest |
3 | 5 | from fastapi_cache import FastAPICache |
4 | | - |
| 6 | +import time_machine |
5 | 7 |
|
6 | 8 | # 1. Does the app start up, and can we use health |
7 | 9 | @pytest.mark.asyncio(loop_scope="session") |
@@ -41,14 +43,20 @@ async def test_national_forecast_horizon_minutes( |
41 | 43 |
|
42 | 44 | We are testing for forecast_horizon of 120 minutes |
43 | 45 | """ |
| 46 | + # make_national_forecast_values makes forecasts from now floored to 30 minutes |
| 47 | + # in half hour intervals back to -7 hours ago. Each forecast is 4.5 hours of 30-minute |
| 48 | + # seperated values. This is a total of 24 unique timestamps. With a horizon of 120, |
| 49 | + # we should lose four of these. |
| 50 | + future_time = dt.datetime.now(tz=dt.UTC) + dt.timedelta(minutes=120, milliseconds=-1) |
| 51 | + with time_machine.travel(future_time, tick=False): |
| 52 | + response = await api_client_uk_national.get( |
| 53 | + "/v0/solar/GB/national/forecast?forecast_horizon_minutes=120" |
| 54 | + ) |
44 | 55 |
|
45 | | - response = await api_client_uk_national.get( |
46 | | - "/v0/solar/GB/national/forecast?forecast_horizon_minutes=120", |
47 | | - ) |
48 | 56 | assert response.status_code == 200 |
49 | 57 | data = response.json() |
50 | 58 | assert isinstance(data, list) |
51 | | - assert len(data) == 16 |
| 59 | + assert len(data) == 20 |
52 | 60 |
|
53 | 61 |
|
54 | 62 | # 2.2 Test the National Forecast, include metadata |
@@ -350,8 +358,8 @@ async def test_gsp_forecast_all_for_one_timestamp_compact( |
350 | 358 | async def test_gsp_pvlive_all( |
351 | 359 | api_client_uk_national, |
352 | 360 | gsp_locations, # noqa arg001 |
353 | | - make_forecasters, # noqa arg001 |
354 | | - make_gsp_forecast_values, # noqa arg001 |
| 361 | + make_observers, # noqa arg001 |
| 362 | + make_gsp_observation_values, # noqa arg001 |
355 | 363 | ) -> None: |
356 | 364 | """Test a sample endpoint for UK National forecast data.""" |
357 | 365 |
|
|
0 commit comments