Skip to content

Commit

Permalink
simplify test
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Garcia Reolid <[email protected]>
  • Loading branch information
victorgarcia98 committed Jul 31, 2023
1 parent cb8c7c5 commit 159d33b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
23 changes: 1 addition & 22 deletions flexmeasures/cli/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

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 @@ -103,7 +100,7 @@ def reporter_config_raw(app, db, setup_dummy_data):

@pytest.mark.skip_github
@pytest.fixture(scope="module")
def process_power_sensor(db, app, setup_markets, setup_sources):
def process_power_sensor(db, app, add_market_prices):
"""
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 @@ -129,24 +126,6 @@ def process_power_sensor(db, app, setup_markets, setup_sources):

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
6 changes: 3 additions & 3 deletions flexmeasures/cli/tests/test_data_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


@pytest.mark.skip_github
def test_add_annotation(app, db, setup_roles_users):
def test_add_annotation(app, fresh_db, setup_roles_users_fresh_db):
from flexmeasures.cli.data_add import add_annotation

cli_input = {
Expand Down Expand Up @@ -52,7 +52,7 @@ def test_add_annotation(app, db, setup_roles_users):


@pytest.mark.skip_github
def test_add_holidays(app, db, setup_roles_users):
def test_add_holidays(app, fresh_db, setup_roles_users_fresh_db):
from flexmeasures.cli.data_add import add_holidays

cli_input = {
Expand Down 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, process_type):
def test_add_process(app, 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 159d33b

Please sign in to comment.