Skip to content

Commit

Permalink
Merge branch 'feature/cli/trigger_shiftable_load' into documentation/…
Browse files Browse the repository at this point in the history
…shiftable_load_tutorial
  • Loading branch information
victorgarcia98 committed Jul 28, 2023
2 parents a646d7e + db85ce4 commit c380f37
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
29 changes: 25 additions & 4 deletions flexmeasures/cli/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

from datetime import datetime, timedelta
from pytz import utc
import pandas as pd

from flexmeasures.data.models.data_sources import DataSource
from flexmeasures.data.models.generic_assets import GenericAsset, GenericAssetType
from flexmeasures.data.models.time_series import Sensor, TimedBelief

from flexmeasures.data.models.planning.utils import initialize_index


@pytest.fixture(scope="module")
@pytest.mark.skip_github
Expand Down Expand Up @@ -100,10 +103,10 @@ def reporter_config_raw(app, db, setup_dummy_data):

@pytest.mark.skip_github
@pytest.fixture(scope="module")
def process_power_sensor(db, app):
def process_power_sensor(db, app, setup_markets, setup_sources):
"""
Create an asset of type "process" and a power sensor to hold the result of
the scheduler.
Create an asset of type "process", power sensor to hold the result of
the scheduler and price data consisting of 8 expensive hours, 8 cheap hours, and again 8 expensive hours-
"""

Expand All @@ -112,7 +115,7 @@ def process_power_sensor(db, app):
db.session.add(process_asset_type)

process_asset = GenericAsset(
name="Test Asset", generic_asset_type=process_asset_type
name="Test Process Asset", generic_asset_type=process_asset_type
)

db.session.add(process_asset)
Expand All @@ -126,6 +129,24 @@ def process_power_sensor(db, app):

db.session.add(power_sensor)

time_slots = initialize_index(
start=pd.Timestamp("2015-01-02").tz_localize("Europe/Amsterdam"),
end=pd.Timestamp("2015-01-03").tz_localize("Europe/Amsterdam"),
resolution="1H",
)
values = [100] * 8 + [90] * 8 + [100] * 8
beliefs = [
TimedBelief(
event_start=dt,
belief_horizon=timedelta(hours=0),
event_value=val,
source=setup_sources["Seita"],
sensor=setup_markets["epex_da"].corresponding_sensor,
)
for dt, val in zip(time_slots, values)
]
db.session.add_all(beliefs)

db.session.commit()

yield power_sensor.id
2 changes: 1 addition & 1 deletion flexmeasures/cli/tests/test_data_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def test_add_reporter(app, db, setup_dummy_data, reporter_config_raw):

@pytest.mark.skip_github
@pytest.mark.parametrize("process_type", [("INFLEXIBLE"), ("SHIFTABLE"), ("BREAKABLE")])
def test_add_process(app, db, process_power_sensor, add_market_prices, process_type):
def test_add_process(app, db, process_power_sensor, process_type):
"""
Schedule a 4h of consumption block at a constant power of 400kW in a day using
the three process policies: INFLEXIBLE, SHIFTABLE and BREAKABLE.
Expand Down

0 comments on commit c380f37

Please sign in to comment.