From 04e727906436a5c20561e2c6baf5d64246b5d675 Mon Sep 17 00:00:00 2001 From: BigTava Date: Mon, 6 May 2024 17:15:53 +0100 Subject: [PATCH] GSYE-724: Add hours of delay to scm settings --- gsy_framework/constants_limits.py | 1 + .../launch_simulation_settings.json | 1 + tests/schema/test_settings_validator.py | 30 +++++++++++-------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/gsy_framework/constants_limits.py b/gsy_framework/constants_limits.py index df065197..4142b141 100644 --- a/gsy_framework/constants_limits.py +++ b/gsy_framework/constants_limits.py @@ -262,6 +262,7 @@ class SCMSettings: INTRACOMMUNITY_BASE_RATE_EUR = None MARKET_ALGORITHM = CoefficientAlgorithm.STATIC.value MARKET_ALGORITHM_LIMIT = RangeLimit(1, 3) + HOURS_OF_DELAY = 72 def is_no_community_self_consumption() -> bool: diff --git a/gsy_framework/schema/avro_schemas/launch_simulation_settings.json b/gsy_framework/schema/avro_schemas/launch_simulation_settings.json index decd967c..8ccbe2a5 100644 --- a/gsy_framework/schema/avro_schemas/launch_simulation_settings.json +++ b/gsy_framework/schema/avro_schemas/launch_simulation_settings.json @@ -27,6 +27,7 @@ {"name": "bid_offer_match_algo", "type": "int"}, {"name": "type", "type": ["null","int"], "default": "undefined"}, {"name": "scm_coefficient_algorithm", "type": ["null", "int"], "default": "null"}, + {"name": "scm_cn_hours_of_delay", "type": ["null", "int"],"default": "null"}, {"name": "scm", "type": [ "null", {"type": "map", "values" : ["float", "int", "string", "null"], "default": {}} diff --git a/tests/schema/test_settings_validator.py b/tests/schema/test_settings_validator.py index d6260000..34f7768c 100644 --- a/tests/schema/test_settings_validator.py +++ b/tests/schema/test_settings_validator.py @@ -38,9 +38,10 @@ def setup_method(self): "name": "DEFAULT_STATIC", "coefficient_algorithm": 2, "grid_fees_reduction": 0.01, - "intracommunity_rate_base_eur": 0.5 + "intracommunity_rate_base_eur": 0.5, + "hours_of_delay": 72, }, - "type": 0 + "type": 0, } @staticmethod @@ -69,6 +70,7 @@ def _assert_all_settings_values(settings: Dict, compare_timedeltas: bool): assert settings["bid_offer_match_algo"] == 1 assert settings["scm"]["name"] == "DEFAULT_STATIC" assert settings["scm"]["coefficient_algorithm"] == 2 + assert settings["scm"]["hours_of_delay"] == 72 assert isclose(settings["scm"]["grid_fees_reduction"], 0.01, rel_tol=0.0000001) assert isclose(settings["scm"]["intracommunity_rate_base_eur"], 0.5, rel_tol=0.0000001) assert settings["type"] == 0 @@ -81,16 +83,20 @@ def test_simulation_settings_validator_works(self): settings = reader.read(decoder) self._assert_all_settings_values(settings, False) - @pytest.mark.parametrize("settings_key, settings_value", [ - ("type", "COLLABORATION"), - ("settlement_market_enabled", 0), - ("scm_coefficient_algorithm", 1.3), - ("bid_offer_match_algo", "payasclear"), - ("relative_std_from_forecast_percent", "ten percent"), - ("currency", "EUR"), - ("external_connection_enabled", "yes"), - ("grid_fee_type", "dynamic"), - ]) + @pytest.mark.parametrize( + "settings_key, settings_value", + [ + ("type", "COLLABORATION"), + ("settlement_market_enabled", 0), + ("scm_coefficient_algorithm", 1.3), + ("scm_cn_hours_of_delay", 72.1), + ("bid_offer_match_algo", "payasclear"), + ("relative_std_from_forecast_percent", "ten percent"), + ("currency", "EUR"), + ("external_connection_enabled", "yes"), + ("grid_fee_type", "dynamic"), + ], + ) def test_simulation_settings_validator_rejects_incorrect_values( self, settings_key: str, settings_value: Any): incorrect_data = deepcopy(self._data)