Merge branch 'enhancement/remove-temporary-form-dictionary-access' into 'master'

Enhancement/remove temporary form dictionary access

See merge request cara/cara!61
This commit is contained in:
Philip James Elson 2020-11-06 22:16:22 +00:00
commit 61ea8a8842
3 changed files with 7 additions and 14 deletions

View file

@ -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)

View file

@ -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.

View file

@ -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 != ""