Index: shared/scripts/configuration/config.py =================================================================== diff -u -re3f67a6e78d267bb99596ba1ce439c6fe7d89a25 -rb4d2f9ef205d7fb355ffd9cd4e5f647dd2c37e9b --- shared/scripts/configuration/config.py (.../config.py) (revision e3f67a6e78d267bb99596ba1ce439c6fe7d89a25) +++ shared/scripts/configuration/config.py (.../config.py) (revision b4d2f9ef205d7fb355ffd9cd4e5f647dd2c37e9b) @@ -130,7 +130,7 @@ "Heparin Stop Time": [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480], "Saline Bolus Volume": [100, 200, 300], "Dialysate Temperature": [35.0, 35.5, 36.0, 36.5, 37.0], - "Blood Pressure Measurement Interval": [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 0], + "Blood Pressure Measurement Interval": [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60], "Rinseback Flow Rate": [50, 75, 100, 125, 150], } @@ -274,7 +274,7 @@ } #Random selection for operational parameter for custom dta -OPERATIONAL_PARAMETERS = {"Heparin Type": HEPARIN_TYPE, "Acid Concentrate": "08-1251-1", +OPERATIONAL_PARAMETERS = {"Heparin Type": HEPARIN_TYPE, "Acid Concentrate": "1.0 K 2.5 Ca", "Bicarbonate Concentrate": BICARBONATE_CONCENTRATE, "Dialyzer Type": "BB Diacap Pro 16H"} #ultrafilteration volume based on flow parameters. Python list contains Rotational speed, Motor speed, @@ -464,12 +464,14 @@ TREATMENT_ALARM_PARAMETER = { "Alarm Id" : [2, 4], + "Alarm Id String" : ["2-HD POST: FPGA Compatibility", 4], "Parameter1" : [2.3, 3.7], "Parameter2" : [3.4, 4.5], } TREATMENT_EVENT_PARAMETER = { "Event id" : [2, 3], + "Event id String" : ["2 - Treatment duration change event", 3], "Old Value" : [1.523, 1.945], "New Value" : [2.523, 3.567], } Index: tst_create_custom_treatment/test.py =================================================================== diff -u -rdaf16428627302767972a5525dd02b8303f9d39a -rb4d2f9ef205d7fb355ffd9cd4e5f647dd2c37e9b --- tst_create_custom_treatment/test.py (.../test.py) (revision daf16428627302767972a5525dd02b8303f9d39a) +++ tst_create_custom_treatment/test.py (.../test.py) (revision b4d2f9ef205d7fb355ffd9cd4e5f647dd2c37e9b) @@ -209,23 +209,46 @@ test.startSection("Verification of duration values") test.compare(waitForObject(names.o_PreTreatmentCreate_duration_SliderCreateTreatment).label, config.DURATION, "Parameter should be -> "+str(config.DURATION)) for duration in config.CREATE_TREATMENT_PARAMETER_RANGE[config.DURATION][::-1]: - test_custom_treatment_slider(names.o_PreTreatmentCreate_durationSlider_Slider, duration, config.CREATE_TREATMENT_SLIDER_VALUES["duration"], config.DURATION) + """ + The function mocking the mouse click encounters a misstep when it comes to a "tight" slider + such as the duration slider, where the segments between ticks are small and causes a misstep. + Setting the x_mouselick_shift to correct the mouse click's x location to get correct values for + special cases: above 330 and at 480 (max value) + """ + x_shift_location = 5 + if duration >= 330 : + x_shift_location = -7 # correcting the automated mouse click + if duration == 480: + x_shift_location = -20 # mouse click was dropping off the slider + test_custom_treatment_slider(names.o_PreTreatmentCreate_durationSlider_Slider, duration, config.CREATE_TREATMENT_SLIDER_VALUES["duration"], config.DURATION, + x_mouseclick_shift=x_shift_location) test.endSection() #scroll the screen to the title heparin bolus volume parameter_object = set_parameter_type(text = config.HEPARIN_BOLUS_VOLUME) utility.scroll_to_zone(parameter_object, names.o_treatment_create_flickable) - test.startSection("Verification of heparin dispensing rate values") + test.startSection("verification of heparin dispensing rate values") test.compare(waitForObject(names.o_PreTreatmentCreate_heparinDispensingRate_SliderCreateTreatment).label, config.HEPARIN_DISPENSING_RATE, "Parameter should be -> "+str(config.HEPARIN_DISPENSING_RATE)) + utils.waitForGUI(1) for heparin_dispensing_rate in config.CREATE_TREATMENT_PARAMETER_RANGE[config.HEPARIN_DISPENSING_RATE][::-1]: test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinDispensingRateSlider_Slider, heparin_dispensing_rate, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_dispensing_rate"], config.HEPARIN_DISPENSING_RATE) test.endSection() - test.startSection("Verification of heparin bolus volume values") + test.startSection("verification of heparin bolus volume values") test.compare(waitForObject(names.o_PreTreatmentCreate_heparinBolusVolume_SliderCreateTreatment).label, config.HEPARIN_BOLUS_VOLUME, "Parameter should be -> "+str(config.HEPARIN_BOLUS_VOLUME)) + mouseClick(names.o_PreTreatmentCreate_heparinBolusVolumeSwitch_Switch) + mouseClick(names.o_PreTreatmentCreate_heparinBolusVolumeSwitch_Switch) + utils.waitForGUI(1) for heparin_bolus_volume in config.CREATE_TREATMENT_PARAMETER_RANGE[config.HEPARIN_BOLUS_VOLUME][::-1]: - test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinBolusVolumeSlider_Slider, heparin_bolus_volume, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_bolus_volume"], config.HEPARIN_BOLUS_VOLUME) + # correcting the automated mouseClick x-location, this is needed for tighter set sliders (segments between ticks are small) + x_shift_location = 0 + if (heparin_bolus_volume == 50) or (heparin_bolus_volume == 20) or (heparin_bolus_volume == 10): + x_shift_location = 5 + + test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinBolusVolumeSlider_Slider, heparin_bolus_volume, + config.CREATE_TREATMENT_SLIDER_VALUES["heparin_bolus_volume"], config.HEPARIN_BOLUS_VOLUME, + x_mouseclick_shift=x_shift_location) test.endSection() #scroll the screen to the title acid concentrate type @@ -235,7 +258,14 @@ test.startSection("Verification of heparin stop time values") test.compare(waitForObject(names.o_PreTreatmentCreate_heparinStopTime_SliderCreateTreatment).label, config.HEPARIN_STOP_TIME, "Parameter should be -> "+str(config.HEPARIN_STOP_TIME)) for heparin_stop_time in config.CREATE_TREATMENT_PARAMETER_RANGE[config.HEPARIN_STOP_TIME][::-1]: - test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinStopTimeSlider_Slider, heparin_stop_time, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_stop_time"], config.HEPARIN_STOP_TIME) + # correcting the automated mouseClick x-location, this is needed for tighter set sliders (segments between ticks are small) + x_shift_location = 0 + if (heparin_stop_time == 50) or (heparin_stop_time == 20): + x_shift_location = 7 + if (heparin_stop_time == 10): + x_shift_location = 15 + test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinStopTimeSlider_Slider, heparin_stop_time, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_stop_time"], config.HEPARIN_STOP_TIME, + x_mouseclick_shift=x_shift_location) test.endSection() test.startSection("Verification of saline bolus values") @@ -258,11 +288,25 @@ parameter_object = names.o_PreTreatmentCreate_bloodPressureMeasurementInterval_SliderCreateTreatment#set_parameter_type(text = config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL) utility.scroll_to_zone(parameter_object, names.o_treatment_create_flickable, yDegreeScrollDisplace = 150) - test.startSection("Verification of blood pressure measurement interval values") + test.startSection("verification of blood pressure measurement interval values") + # TODO need to figure out if the switch should be OFF or on. based on application behavior, it stays on. + # off_label= utility.get_object_from_names(names.o_PreTreatmentCreate_BPInterval_OFF_Text, error_message = "off label object missing") + # if off_label is not None: + # test.compare(waitForObject(names.o_PreTreatmentCreate_BPInterval_OFF_Text).text,"OFF", "Text should be -> "+"OFF") + mouseClick(waitForObject(names.o_PreTreatmentCreate_BPInterval_Switch)) + mouseClick(names.o_PreTreatmentCreate_BPInterval_Switch) + utils.waitForGUI(1) test.compare(waitForObject(names.o_PreTreatmentCreate_bloodPressureMeasurementInterval_SliderCreateTreatment).label, config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL, "Parameter should be -> "+str(config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL)) for blood_pressure_measurement_interval in config.CREATE_TREATMENT_PARAMETER_RANGE[config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL][::-1]: - test_custom_treatment_slider(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalSlider_Slider, blood_pressure_measurement_interval, config.CREATE_TREATMENT_SLIDER_VALUES["blood_pressure_measurement_interval"], config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL) - test.compare(config.OFF_TEXT, waitForObject(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalValue_Text).text, "OFF text should display for value 0") + """ + The function mocking the mouse click encounters a misstep in traversing between tick marks, need to correct + """ + x_shift_location = 15 + if blood_pressure_measurement_interval >= 40 : + x_shift_location = 60 # correcting the automated mouse click + + test_custom_treatment_slider(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalSlider_Slider, blood_pressure_measurement_interval, config.CREATE_TREATMENT_SLIDER_VALUES["blood_pressure_measurement_interval"], config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL, + x_mouseclick_shift=x_shift_location) test.endSection() test_continue_button() @@ -325,7 +369,7 @@ test.endSection() -def test_custom_treatment_slider(slider_object, value, slider_parameter, parameter): +def test_custom_treatment_slider(slider_object, value, slider_parameter, parameter, x_mouseclick_shift = 0): """ Method to set slider handle based on custom values @param slider_object : (dictionary) object of treatment parameters @@ -336,10 +380,9 @@ minimum_slider_value = slider_parameter[0] slider_buffer = slider_parameter[1] width_buffer = slider_parameter[2] - slider_width = ((value - minimum_slider_value)/slider_buffer) * width_buffer - utils.waitForGUI(0.2) + slider_width = ((value - minimum_slider_value)/slider_buffer) * width_buffer + x_mouseclick_shift mouseClick(waitForObjectExists(slider_object), float(slider_width) , 3, Qt.LeftButton) - + utils.waitForGUI(0.5) test.compare(waitForObjectExists(slider_object).value, value, str(parameter)+" slider value should set to " +str(value)) @@ -387,13 +430,13 @@ test.compare(waitForObject(names.o_PreTreatmentCreate_Create_a_Custom_Treatment_Text).text, config.TREATMENT_TITLE, "Title text should be -> "+str(config.TREATMENT_TITLE)) test.compare(waitForObject(names.o_PreTreatmentCreate_PRESCRIPTION_Text).text, config.PRESCRIPTION_TITLE, "Title text should be -> "+str(config.PRESCRIPTION_TITLE)) - #set custom values for parameters + # set custom values for parameters test.startSection("Verification of blood flow values") test.compare(waitForObject(names.o_PreTreatmentCreate_bloodFlowRate_SliderCreateTreatment).label, config.BLOOD_FLOW_RATE, "Parameter should be -> "+str(config.BLOOD_FLOW_RATE)) for blood_flow_rate in config.CREATE_TREATMENT_PARAMETER_RANGE[config.BLOOD_FLOW_RATE]: test_custom_treatment_slider(names.o_PreTreatmentCreate_bloodFlowRateSlider_Slider, blood_flow_rate, config.CREATE_TREATMENT_SLIDER_VALUES["blood_flow_rate"], config.BLOOD_FLOW_RATE) test.endSection() - + test.startSection("Verification of dialysate flow values") test.compare(waitForObject(names.o_PreTreatmentCreate_dialysateFlowRate_SliderCreateTreatment).label, config.DIALYSATE_FLOW_RATE, "Parameter should be -> "+str(config.DIALYSATE_FLOW_RATE)) for dialysate_flow_rate in config.CREATE_TREATMENT_PARAMETER_RANGE[config.DIALYSATE_FLOW_RATE]: @@ -403,7 +446,20 @@ test.startSection("Verification of duration values") test.compare(waitForObject(names.o_PreTreatmentCreate_duration_SliderCreateTreatment).label, config.DURATION, "Parameter should be -> "+str(config.DURATION)) for duration in config.CREATE_TREATMENT_PARAMETER_RANGE[config.DURATION]: - test_custom_treatment_slider(names.o_PreTreatmentCreate_durationSlider_Slider, duration, config.CREATE_TREATMENT_SLIDER_VALUES["duration"], config.DURATION) + """ + The function mocking the mouse click encounters a misstep when it comes to a "tight" slider + such as the duration slider, where the segments between ticks are small and causes a misstep. + Setting the x_mouselick_shift to correct the mouse click's x location to get correct values for + special cases: above 330 and at 480 (max value) + """ + x_shift_location = 5 + if duration >= 330 : + x_shift_location = -7 # correcting the automated mouse click + if duration == 480: + x_shift_location = -20 # mouse click was dropping off the slider + test_custom_treatment_slider(names.o_PreTreatmentCreate_durationSlider_Slider, duration, + config.CREATE_TREATMENT_SLIDER_VALUES["duration"], config.DURATION, + x_mouseclick_shift=x_shift_location) test.endSection() #scroll the screen to the title heparin bolus volume @@ -439,7 +495,15 @@ test.startSection("Verification of heparin stop time values") test.compare(waitForObject(names.o_PreTreatmentCreate_heparinStopTime_SliderCreateTreatment).label, config.HEPARIN_STOP_TIME, "Parameter should be -> "+str(config.HEPARIN_STOP_TIME)) for heparin_stop_time in config.CREATE_TREATMENT_PARAMETER_RANGE[config.HEPARIN_STOP_TIME]: - test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinStopTimeSlider_Slider, heparin_stop_time, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_stop_time"], config.HEPARIN_STOP_TIME) + # correcting the automated mouseClick x-location, this is needed for tighter set sliders (segments between ticks are small) + x_shift_location = 0 + if (heparin_stop_time == 50) or (heparin_stop_time == 20): + x_shift_location = 5 + if (heparin_stop_time == 10): + x_shift_location = 15 + + test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinStopTimeSlider_Slider, heparin_stop_time, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_stop_time"], config.HEPARIN_STOP_TIME, + x_mouseclick_shift=x_shift_location) test.endSection() test.startSection("Verification of saline bolus values") @@ -540,8 +604,14 @@ utils.waitForGUI(1) test.compare(waitForObject(names.o_PreTreatmentCreate_bloodPressureMeasurementInterval_SliderCreateTreatment).label, config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL, "Parameter should be -> "+str(config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL)) for blood_pressure_measurement_interval in config.CREATE_TREATMENT_PARAMETER_RANGE[config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL]: - test_custom_treatment_slider(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalSlider_Slider, blood_pressure_measurement_interval, config.CREATE_TREATMENT_SLIDER_VALUES["blood_pressure_measurement_interval"], config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL) - test.compare(config.OFF_TEXT, waitForObject(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalValue_Text).text, "OFF text should display for value 0") + """ + The function mocking the mouse click encounters a misstep in traversing between tick marks, need to correct + """ + x_shift_location = 15 + if blood_pressure_measurement_interval >= 40 : + x_shift_location = 60 # correcting the automated mouse click + test_custom_treatment_slider(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalSlider_Slider, blood_pressure_measurement_interval, config.CREATE_TREATMENT_SLIDER_VALUES["blood_pressure_measurement_interval"], config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL, + x_mouseclick_shift=x_shift_location) test.endSection() test.endSection() @@ -608,8 +678,12 @@ test_custom_treatment_slider(names.o_PreTreatmentCreate_dialysateTemperatureSlider_Slider, config.CREATE_CUSTOM_TREATMENT[config.DIALYSATE_TEMPERATURE], config.CREATE_TREATMENT_SLIDER_VALUES["dialysate_temperature"], config.DIALYSATE_TEMPERATURE) - #set custom values for parameters - test_custom_treatment_slider(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalSlider_Slider, config.CREATE_CUSTOM_TREATMENT[config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL], config.CREATE_TREATMENT_SLIDER_VALUES["blood_pressure_measurement_interval"], config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL) + #set custom values for parameters + mouseClick(waitForObject(names.o_PreTreatmentCreate_BPInterval_Switch)) + mouseClick(names.o_PreTreatmentCreate_BPInterval_Switch) + utils.waitForGUI(1) + test.compare(waitForObject(names.o_PreTreatmentCreate_bloodPressureMeasurementInterval_SliderCreateTreatment).label, config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL, "Parameter should be -> "+str(config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL)) + test_custom_treatment_slider(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalSlider_Slider, config.CREATE_CUSTOM_TREATMENT[config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL], config.CREATE_TREATMENT_SLIDER_VALUES["blood_pressure_measurement_interval"], config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL, x_mouseclick_shift=25) test.endSection() Index: tst_post_treatment/test.py =================================================================== diff -u -rc79559a8ecd6dc676c7aed956ba1a5d1e45534a0 -rb4d2f9ef205d7fb355ffd9cd4e5f647dd2c37e9b --- tst_post_treatment/test.py (.../test.py) (revision c79559a8ecd6dc676c7aed956ba1a5d1e45534a0) +++ tst_post_treatment/test.py (.../test.py) (revision b4d2f9ef205d7fb355ffd9cd4e5f647dd2c37e9b) @@ -22,6 +22,7 @@ import os import test import builtins +from builtins import int as pyInt from pathlib import Path from dialin.ui import utils from datetime import * @@ -367,6 +368,10 @@ for parameters_value in config.POST_TREATMENT_REVIEW_PARAMETER_RANGE.keys(): parameter_set = config.POST_TREATMENT_REVIEW_PARAMETER_RANGE[parameters_value] + + # get values from treatment log file + parameter_value, parameter_unit = verify_parameter_from_post_treatment_log(parameters_value) + #TODO: Following six parameters are not available on UI but API command is requiring this argument for logging. if parameters_value == "Device ID": continue @@ -428,9 +433,14 @@ review_parameter_value = review_text(text = string_cmp) test.log(str(review_parameter_value)) parameter_text = waitForObjectExists(review_parameter_value) + test.log(f"{string_cmp} {str(parameter_text.text)}") test.compare(string_cmp, str(parameter_text.text), "parameter value should be "+str(string_cmp)) continue - + elif parameters_value == "Patient ID": + # patient ID has no unit + parameter_value, parameter_unit = verify_parameter_from_post_treatment_log(parameters_value) + test.compare(parameter_value, parameter_set[index], "parameters value should be ->" + str(parameter_set[index])) + continue if parameters_value == 'Treatment Start DateTime': start_date_time = datetime.fromtimestamp(parameter_set[index]).strftime('%Y/%m/%d %H:%M') review_parameter_value = review_text(text = str(start_date_time)) @@ -448,29 +458,28 @@ else: if isinstance(parameter_set[index], float): parameter_set[index] = ('%.3f' %parameter_set[index]) - test.log("verification of values for parameter" + str(parameter_to_scroll)) + test.log("verification of values for parameter " + str(parameter_to_scroll)) parameter_to_scroll = str(parameter_set[index]) if parameters_value == "Treatment Duration": time_duration = builtins.int(utility.convert_seconds_into_min_and_sec(seconds=parameter_to_scroll, time_format="%M")) if time_duration < 1 : - parameter_to_scroll = "0" + parameter_value = "0" else: - parameter_to_scroll = str(time_duration) + parameter_value = str(time_duration) + test.compare(parameter_to_scroll, str(parameter_set[index]), "raw treatment time parameters value should be ->" + str(parameter_set[index])) + continue if parameters_value == 'Actual Treatment Duration': time_duration = builtins.int(utility.convert_seconds_into_min_and_sec(seconds=parameter_to_scroll, time_format="%M")) test.log(str(time_duration)) - parameter_to_scroll = str(time_duration) - - # review_parameter_value = review_text(text = parameter_to_scroll) - # parameter_text = waitForObjectExists(review_parameter_value) - # test.log("###verification of values for parameter - >" + parameters_value + " from UI screen") - # parameter_set[index] = parameter_to_scroll - # test.compare(str(parameter_set[index]), str(parameter_text.text), "parameter value should be "+str(parameter_set[index])) + parameter_value = str(time_duration) + test.compare(parameter_to_scroll, str(parameter_set[index]), "raw actual time parameters value should be ->" + str(parameter_set[index])) + continue + test.log("verification of post treatment log file data") - parameter_value, parameter_unit = verify_parameter_from_post_treatment_log(parameters_value) - test.compare(parameter_unit, config.POST_TREATMENT_REVIEW_SCREEN_UNITS[parameters_value], "parameters unit should be ->" + config.POST_TREATMENT_REVIEW_SCREEN_UNITS[parameters_value]) - test.compare(parameter_value, parameter_set[index], "parameters value should be ->" + str(parameter_set[index])) + test.log(f"{parameters_value} = {parameter_value} {parameter_unit}") + test.compare(parameter_unit, config.POST_TREATMENT_REVIEW_SCREEN_UNITS[parameters_value], "parameters unit should be ->"+ config.POST_TREATMENT_REVIEW_SCREEN_UNITS[parameters_value]) + test.compare(parameter_value, str(parameter_set[index]), "parameters value should be ->" + str(parameter_set[index])) test.endSection() test.endSection() @@ -482,8 +491,9 @@ test.startSection("Verification of treatment data") log_data = get_message_from_log("[Treatment Data]",parameter_count=9) for index in range (1): - test.compare(log_data[1], str(config.TREATMENT_DATA_PARAMETER["Blood flow rate"][index]), "parameters value should be ->" + str(config.TREATMENT_DATA_PARAMETER["Blood flow rate"][index])) - test.compare(log_data[2], str(config.TREATMENT_DATA_PARAMETER["Dialysate flow rate"][index]), "parameters value should be ->" + str(config.TREATMENT_DATA_PARAMETER["Dialysate flow rate"][index])) + + test.compare(log_data[1], "{val:.3f}".format(val=config.TREATMENT_DATA_PARAMETER["Blood flow rate"][index]), "parameters value should be ->" + str(config.TREATMENT_DATA_PARAMETER["Blood flow rate"][index])) + test.compare(log_data[2], "{val:.3f}".format(val=config.TREATMENT_DATA_PARAMETER["Dialysate flow rate"][index]), "parameters value should be ->" + str(config.TREATMENT_DATA_PARAMETER["Dialysate flow rate"][index])) test.compare(log_data[3], str(config.TREATMENT_DATA_PARAMETER["Uf rate"][index]), "parameters value should be ->" + str(config.TREATMENT_DATA_PARAMETER["Uf rate"][index])) test.compare(log_data[4], str(config.TREATMENT_DATA_PARAMETER["Arterial pressure"][index]), "parameters value should be ->" + str(config.TREATMENT_DATA_PARAMETER["Arterial pressure"][index])) test.compare(log_data[5], str(config.TREATMENT_DATA_PARAMETER["Venous pressure"][index]), "parameters value should be ->" + str(config.TREATMENT_DATA_PARAMETER["Venous pressure"][index])) @@ -497,9 +507,9 @@ test.startSection("Verification of treatment alarm data") log_data = get_message_from_log("[Treatment Alarms]",parameter_count=4) for index in range (1): - test.compare(log_data[1], str(config.TREATMENT_ALARM_PARAMETER["Alarm Id"][index]), "parameters value should be ->" + str(config.TREATMENT_ALARM_PARAMETER["Alarm Id"][index])) - test.compare(log_data[2], str(config.TREATMENT_ALARM_PARAMETER["Parameter1"][index]), "parameters value should be ->" + str(config.TREATMENT_ALARM_PARAMETER["Parameter1"][index])) - test.compare(log_data[3], str(config.TREATMENT_ALARM_PARAMETER["Parameter2"][index]), "parameters value should be ->" + str(config.TREATMENT_ALARM_PARAMETER["Parameter2"][index])) + test.compare(log_data[1].strip(), str(config.TREATMENT_ALARM_PARAMETER["Alarm Id String"][index]), "parameters value should be ->" + str(config.TREATMENT_ALARM_PARAMETER["Alarm Id"][index])) + test.compare(log_data[2].strip(), str(config.TREATMENT_ALARM_PARAMETER["Parameter1"][index]), "parameters value should be ->" + str(config.TREATMENT_ALARM_PARAMETER["Parameter1"][index])) + test.compare(log_data[3].strip(), str(config.TREATMENT_ALARM_PARAMETER["Parameter2"][index]), "parameters value should be ->" + str(config.TREATMENT_ALARM_PARAMETER["Parameter2"][index])) test.endSection() @@ -510,9 +520,9 @@ test.startSection("Verification of treatment event data") log_data = get_message_from_log("[Treatment Events]",parameter_count=4) for index in range (1): - test.compare(log_data[1], str(config.TREATMENT_EVENT_PARAMETER["Event id"][index]), "parameters value should be ->" + str(config.TREATMENT_EVENT_PARAMETER["Event id"][index])) - test.compare(log_data[2], str(config.TREATMENT_EVENT_PARAMETER["Old Value"][index]), "parameters value should be ->" + str(config.TREATMENT_EVENT_PARAMETER["Old Value"][index])) - test.compare(log_data[3], str(config.TREATMENT_EVENT_PARAMETER["New Value"][index]), "parameters value should be ->" + str(config.TREATMENT_EVENT_PARAMETER["New Value"][index])) + test.compare(log_data[1].strip(), str(config.TREATMENT_EVENT_PARAMETER["Event id String"][index]), "parameters value should be ->" + str(config.TREATMENT_EVENT_PARAMETER["Event id"][index])) + test.compare(log_data[2].strip(), str(config.TREATMENT_EVENT_PARAMETER["Old Value"][index]), "parameters value should be ->" + str(config.TREATMENT_EVENT_PARAMETER["Old Value"][index])) + test.compare(log_data[3].strip(), str(config.TREATMENT_EVENT_PARAMETER["New Value"][index]), "parameters value should be ->" + str(config.TREATMENT_EVENT_PARAMETER["New Value"][index])) test.endSection() @@ -555,20 +565,21 @@ """ try: log_location = str(utility.get_extracted_file_from_post_treatment()) - with open(log_location, 'r') as csv_file: - - try: - for row in csv_file: - reader = csv.reader(csv_file) - for row in reader: - row_length = sum(1 for values in row) - for row1 in row: - if row[0]!= None and row[0] == msg_text and row_length == 3: - return (row[1],row[2]) - else: - pass - except: - test.fail("Treatment log data is corrupted") + if log_location is not False: + with open(log_location, 'r') as csv_file: + try: + for row in csv_file: + columns = row.split(',') + if columns[0] == msg_text and len(columns) == 3: + return (columns[1].strip(),columns[2].strip()) + elif columns[0] == msg_text and len(columns) == 2: + return (columns[1].strip(),columns[1].strip()) + else: + pass + except: + test.fail("Treatment log data is corrupted") + else: + test.fail("Log file is not created or log file is not created based on standard log naming format.") except: test.fail("Log file is not created or log file is not created based on standard log naming format.") return (-1, -1)