3
3
import os
4
4
from datetime import datetime , timedelta
5
5
6
+ import pandas as pd
6
7
import pytest
7
8
from pvsite_datamodel .sqlmodels import Base , ForecastSQL , ForecastValueSQL , GenerationSQL , SiteSQL
8
9
from pvsite_datamodel .read .user import get_user_by_email
@@ -144,17 +145,12 @@ def make_fake_forecast_values(db_session, sites, model_name):
144
145
forecast_values = []
145
146
forecast_version : str = "0.0.0"
146
147
147
- num_forecasts = 10
148
- num_values_per_forecast = 11
148
+ num_forecasts = 12 # 2 hours in 10 minute blocks
149
+ num_values_per_forecast = 11 # 2.5 hours in 15 minute blocks, including init time
150
+ # Total forecast range should be 4.5 hours, which is 18 values
149
151
150
- now = datetime .utcnow ()
151
- rounded_now_30_mins = now .replace (microsecond = 0 ,second = 0 )
152
- if now .minute >= 30 :
153
- rounded_now_30_mins = rounded_now_30_mins .replace (minute = 30 )
154
- else :
155
- rounded_now_30_mins = rounded_now_30_mins .replace (minute = 0 )
156
-
157
- timestamps = [rounded_now_30_mins - timedelta (minutes = 15 * i ) for i in range (num_forecasts )]
152
+ init_time = datetime .utcnow () - timedelta (hours = 2 )
153
+ timestamps = [init_time + timedelta (minutes = 10 * i ) for i in range (num_forecasts )]
158
154
159
155
# To make things trickier we make a second forecast at the same for one of the timestamps.
160
156
timestamps = timestamps + timestamps [- 1 :]
@@ -168,6 +164,9 @@ def make_fake_forecast_values(db_session, sites, model_name):
168
164
site_uuid = site .site_uuid , forecast_version = forecast_version , timestamp_utc = timestamp
169
165
)
170
166
167
+ timestamp = pd .Timestamp (timestamp )
168
+ timestamp = timestamp .floor ('15min' )
169
+
171
170
db_session .add (forecast )
172
171
db_session .commit ()
173
172
0 commit comments