diff --git a/cara/apps/calculator/__init__.py b/cara/apps/calculator/__init__.py index 3a63ad04..e0f7a5f4 100644 --- a/cara/apps/calculator/__init__.py +++ b/cara/apps/calculator/__init__.py @@ -21,10 +21,6 @@ class ConcentrationModel(RequestHandler): try: form = model_generator.FormData.from_dict(requested_model_config) - model = form.build_model( - # TODO: This argument to be removed. - tmp_raw_form_data=requested_model_config, - ) except (KeyboardInterrupt, SystemExit): raise except Exception as err: @@ -36,7 +32,7 @@ class ConcentrationModel(RequestHandler): self.finish(json.dumps(response_json)) return - report = build_report(model, form) + report = build_report(form.build_model(), form) self.finish(report) diff --git a/cara/apps/calculator/model_generator.py b/cara/apps/calculator/model_generator.py index 907a78b2..93ef2dd0 100644 --- a/cara/apps/calculator/model_generator.py +++ b/cara/apps/calculator/model_generator.py @@ -107,9 +107,8 @@ class FormData: infected_finish=time_string_to_minutes(form_data['infected_finish']), ) - # TODO: Remove the tmp_raw_form_data usage. - def build_model(self, tmp_raw_form_data) -> Model: - return model_from_form(self, tmp_raw_form_data) + def build_model(self) -> Model: + return model_from_form(self) def ventilation(self) -> models.Ventilation: # Initializes a ventilation instance as a window if 'natural' is selected, or as a HEPA-filter otherwise @@ -212,9 +211,7 @@ class FormData: return models.SpecificInterval(tuple(present_intervals)) -def model_from_form(form: FormData, tmp_raw_form_data) -> models.Model: - d = tmp_raw_form_data - +def model_from_form(form: FormData) -> models.Model: # Initializes room with volume either given directly or as product of area and height if form.volume_type == 'room_volume': volume = form.room_volume @@ -227,7 +224,7 @@ def model_from_form(form: FormData, tmp_raw_form_data) -> models.Model: # Initializes a mask of type 1 if mask wearing is "continuous", otherwise instantiates the mask attribute as # the "No mask"-mask - mask = models.Mask.types['Type I' if d['mask_wearing'] == "continuous" else 'No mask'] + mask = models.Mask.types['Type I' if form.mask_wearing == "continuous" else 'No mask'] # A dictionary containing the mapping of activities listed in the UI to the activity level and expiration level # of the infected and exposed occupants respectively. diff --git a/cara/tests/apps/calculator/test_report_generator.py b/cara/tests/apps/calculator/test_report_generator.py index f8cedafb..5bb7d719 100644 --- a/cara/tests/apps/calculator/test_report_generator.py +++ b/cara/tests/apps/calculator/test_report_generator.py @@ -14,8 +14,8 @@ def baseline_form(baseline_form_data): return model_generator.FormData.from_dict(baseline_form_data) -def test_generate_report(baseline_form, baseline_form_data): - model = baseline_form.build_model(baseline_form_data) +def test_generate_report(baseline_form): + model = baseline_form.build_model() report = report_generator.build_report(model, baseline_form) assert report != ""