6
6
import pytest
7
7
from pvsite_datamodel .sqlmodels import Base , ForecastSQL , ForecastValueSQL , GenerationSQL , SiteSQL
8
8
from pvsite_datamodel .read .user import get_user_by_email
9
+ from pvsite_datamodel .read .model import get_or_create_model
9
10
from sqlalchemy import create_engine
10
11
from sqlalchemy .orm import Session
11
12
from testcontainers .postgres import PostgresContainer
@@ -123,6 +124,23 @@ def generations(db_session, sites):
123
124
@pytest .fixture ()
124
125
def forecast_values (db_session , sites ):
125
126
"""Create some fake forecast values"""
127
+
128
+ make_fake_forecast_values (db_session , sites , "pvnet_india" )
129
+
130
+ @pytest .fixture ()
131
+ def forecast_values_wind (db_session , sites ):
132
+ """Create some fake forecast values"""
133
+
134
+ make_fake_forecast_values (db_session , sites , "windnet_india" )
135
+
136
+ @pytest .fixture ()
137
+ def forecast_values_site (db_session , sites ):
138
+ """Create some fake forecast values"""
139
+
140
+ make_fake_forecast_values (db_session , sites , "pvnet_ad_sites" )
141
+
142
+
143
+ def make_fake_forecast_values (db_session , sites , model_name ):
126
144
forecast_values = []
127
145
forecast_version : str = "0.0.0"
128
146
@@ -134,6 +152,9 @@ def forecast_values(db_session, sites):
134
152
# To make things trickier we make a second forecast at the same for one of the timestamps.
135
153
timestamps = timestamps + timestamps [- 1 :]
136
154
155
+ # get model
156
+ ml_model = get_or_create_model (db_session , model_name )
157
+
137
158
for site in sites :
138
159
for timestamp in timestamps :
139
160
forecast : ForecastSQL = ForecastSQL (
@@ -154,6 +175,7 @@ def forecast_values(db_session, sites):
154
175
end_utc = timestamp + timedelta (minutes = horizon + duration ),
155
176
horizon_minutes = horizon ,
156
177
)
178
+ forecast_value .ml_model = ml_model
157
179
158
180
forecast_values .append (forecast_value )
159
181
0 commit comments