From 159d33b03df0e4c19af6798ae4ce98db3febd7c7 Mon Sep 17 00:00:00 2001 From: Victor Garcia Reolid Date: Mon, 31 Jul 2023 13:03:53 +0200 Subject: [PATCH] simplify test Signed-off-by: Victor Garcia Reolid --- flexmeasures/cli/tests/conftest.py | 23 +---------------------- flexmeasures/cli/tests/test_data_add.py | 6 +++--- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/flexmeasures/cli/tests/conftest.py b/flexmeasures/cli/tests/conftest.py index 300b6541c..5b1f8b90b 100644 --- a/flexmeasures/cli/tests/conftest.py +++ b/flexmeasures/cli/tests/conftest.py @@ -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 @@ -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- @@ -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 diff --git a/flexmeasures/cli/tests/test_data_add.py b/flexmeasures/cli/tests/test_data_add.py index 3cf35c04c..77935deea 100644 --- a/flexmeasures/cli/tests/test_data_add.py +++ b/flexmeasures/cli/tests/test_data_add.py @@ -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 = { @@ -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 = { @@ -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.