diff --git a/cara/apps/calculator/model_generator.py b/cara/apps/calculator/model_generator.py index 89366b04..2e10b1f2 100644 --- a/cara/apps/calculator/model_generator.py +++ b/cara/apps/calculator/model_generator.py @@ -254,6 +254,11 @@ class FormData: "window_opening_regime cannot be 'not-applicable' if " "ventilation_type is 'natural_ventilation'" ) + if (self.window_opening_regime == 'windows_open_periodically' and + self.windows_duration > self.windows_frequency): + raise ValueError( + 'Duration cannot be bigger than frequency.' + ) if (self.ventilation_type == 'mechanical_ventilation' and self.mechanical_ventilation_type == 'not-applicable'): diff --git a/cara/tests/apps/calculator/test_model_generator.py b/cara/tests/apps/calculator/test_model_generator.py index f925497e..c1d1f2c2 100644 --- a/cara/tests/apps/calculator/test_model_generator.py +++ b/cara/tests/apps/calculator/test_model_generator.py @@ -508,6 +508,14 @@ def test_key_validation_natural_ventilation_window_opening_regime_na(baseline_fo model_generator.FormData.from_dict(baseline_form_data) +def test_natural_ventilation_window_opening_periodically(baseline_form: model_generator.FormData): + baseline_form.window_opening_regime = 'windows_open_periodically' + baseline_form.windows_duration = 20 + baseline_form.windows_frequency = 10 + with pytest.raises(ValueError, match='Duration cannot be bigger than frequency.'): + baseline_form.validate() + + def test_key_validation_mech_ventilation_type_na(baseline_form_data): baseline_form_data['ventilation_type'] = 'mechanical_ventilation' baseline_form_data['mechanical_ventilation_type'] = 'not-applicable'