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)