# Subject/Title : LDT -3449 Water, Dialysate, and Blood Sampling - SW - 02 - Water sample & Dialysate Checks - Q&R - 15: SIT - Software Integration Tests - Squish Qt # LDT-4207 NON-FEATURE: SW Misc & Enhc - SW - 02 - Water/Dialysate Sample - Q&R # Functionalities: Testing all functionalities of Water, Dialysate, and Blood Sampling checks # # Steps: # Dialsyate and Water Sampling: # 1 Navigate to create treatement and set Acid concentrate value # 2 Click on Water sample option and check Water sample dialog page is visible # 3 Press the water sample icon and the FW broadcasted Water Sample Data will provide Valve (1 or 2) # - Test the string should say primary for valve 1 and secondary for valve 2 # 4 Test send the Water sample result request and FW receives the value # - the last result and time stamp should be displayed after the FW response # 5 Close the dialog. On the Water Sample Data broad case when switching from OFF -> Timed Out the UI should open the water sample dialog # 6 Navigate to dialysate tab and check the acid concentrate value import names import can from leahi_dialin.ui import utils from configuration import utility,config,navigation from configuration import config from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.common.ui_defs import TXStates from leahi_dialin.common.td_defs import TDOpModes,TDTreatmentStates from leahi_dialin.protocols import CAN from leahi_dialin.utils import conversions from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions td =TD_Messaging() watersample = None can_interface = td.can_interface # handler for messages from UI to FW def handle_water_sample_request( message, timestamp = 0.0): """ Called when the user requests to firmware from UI @return: None """ global watersample watersample = True def set_value_based_on_target(obj, target_value): """ obj: dictionary containing object paths Example: { "value_obj": ":mainTreatmentScreen.PressureText", "left_arrow": ":mainTreatmentScreen.LeftArrow", "right_arrow": ":mainTreatmentScreen.RightArrow" } target_value: integer or string number, e.g. 220 """ target_value = target_value # Wait for all objects parent_obj = waitForObject(obj) # change range as per your screen count left_arrow = utility.findObjectById(parent_obj, "_leftArrow") right_arrow =utility.findObjectById(parent_obj, "_rightArrow") # Read current value (supports invisible text too) current_value = round(float(waitForObject(obj).value), 2) # Determine direction while current_value != float(target_value): if current_value < float(target_value): mouseClick(waitForObject(right_arrow)) elif current_value > float(target_value): mouseClick(waitForObject(left_arrow)) current_value = round(float(waitForObject(obj).value), 2) test.log(f"Updated value: {current_value}") test.log(f" Target value reached: {current_value}") def set_acid_concentrate(): test.startSection("Set acid concentrate") navigation.navigation_pageIndicator_step(config.CREATERX) patient_id = waitForObject(names.o_PreTreatmentCreate_patientID_LabelUnitContainer) patient_id_edit = utility.findObjectById(patient_id, "_editButton") mouseClick(patient_id_edit) mouseClick(waitForObject(names.o_pretreatmentPatientIDEntry_TextEntry)) # type(waitForObject(names.o_pretreatmentPatientIDEntry_TextEntry),"Test") waitForObject(names.o_pretreatmentPatientIDEntry_TextEntry).text ="abcd" mouseClick(waitForObject(names.o_HeaderBar_WiFi_Popup), 611, 343, Qt.LeftButton) mouseClick(waitForObject(names.o_confirmButton_ConfirmButton)) utility.select_different_dropdown(names.o_PreTreatmentCreate_acidConcentrateComboBox_BaseComboBox,config.ACID_CONCENTRATE,2) test.endSection() def water_sample_tab(): test.startSection("Test Water Sample Result Messgae") mouseClick(waitForObject(names.o_waterSample_IconButton)) water_sample = waitForObject(names.o_menu_MainMenu) test.compare(water_sample.visible,True ,"Water sample dialog is visible") td.td_water_sample(valve = 0, timeout = 0 ) parent_obj = waitForObject(names.o_waterSample_WaterSamplePage) test_primary = utility.findObjectById(parent_obj, "_message") test.compare(test_primary.text, config.TEST_PRIMARY, "{} should be primary when valve is 1".format(test_primary.text)) td.td_water_sample(valve = 1, timeout = 0 ) test_secondary = utility.findObjectById(parent_obj, "_message") test.compare(test_secondary.text, config.TEST_SECONDARY, "{} should be secondary when valve is 2".format(test_secondary.text)) set_value_based_on_target(names.o_LabelUnitValueAdjuster_LabelUnitValueAdjuster, 0.14) mouseClick(names.o_confirmButton_TouchRect) # handle sent messages from UI global watersample if can_interface is not None: channel_id = CAN.CanChannels.ui_to_td_ch_id message_id = MsgIds.MSG_ID_UI_WATER_SAMPLE_RESULT_REQUEST.value can_interface.register_receiving_publication_function(channel_id, message_id, handle_water_sample_request) test.verify(waitFor(lambda: watersample == True, 3000), f"Testing FW received") td.td_water_sample_result_response( vAccepted = 1 , vRejectionReason = 0 , vValue = 1.0) mouseClick(names.o_waterSample_IconButton) last_tested = utility.findObjectById(parent_obj, "_lastRecorded") test.verify(last_tested.visible, "Last tested text is visible") last_result = utility.findObjectById(parent_obj,"_lastValue") test.verify(last_result.visible, "Last result text is visible") td.td_water_sample_result_response( vAccepted = 1 , vRejectionReason = 0 , vValue = 1.0) td.td_water_sample(valve = 1, timeout = 1 ) popup_obj = waitForObject(names.o_PopupItem) test.verify(popup_obj.visible, "Water sample popup is visible") test.endSection() def dialysate_tab(): test.startSection("Check the values in the dialysate tab") dialysate_checks = waitForObject(names.o_touchRect1_TouchRect) dialysate_checks_text =utility.findChildByText(dialysate_checks, "Dialysate Checks") mouseClick(waitForObject(dialysate_checks_text)) acid_concentrate = waitForObject(names.o_acidConcentrateContainer_LabelUnitContainer) acid_concentrate_text = utility.findObjectById(acid_concentrate,"_acidConcentrateText") test.log(str(acid_concentrate_text.text)) bicarbonate_cartridge = waitForObject(names.o_bicarbonateCartrideSizeContainer_LabelUnitContainer) bicarbonate_cartridge_text = utility.findObjectById(bicarbonate_cartridge,"_bicarbonateCartrideSizeText") test.log(str(bicarbonate_cartridge_text.text)) sodium = waitForObject(names.o_sodiumContainer_LabelUnitContainer) sodium_text = utility.findObjectById(sodium,"_sodiumText") test.log(str(sodium_text.text)) bicarbonate = waitForObject(names.o_bicarbonateContainer_LabelUnitContainer) bicarbonate_text = utility.findObjectById(bicarbonate,"_bicarbonateText") test.log(str(bicarbonate_text.text)) theoritical_Condictivity = waitForObject(names.o_theoriticalCondictivityContainer_LabelUnitContainer) theoritical_Condictivity_text =utility.findObjectById(theoritical_Condictivity,"_theoriticalCondictivityText") test.log(str(theoritical_Condictivity_text.text)) independent_Conductivity_Reading1 = waitForObject(names.o_independentConductivityReadingContainer1_LabelUnitContainer) independent_Conductivity_Reading1_text = utility.findObjectById(independent_Conductivity_Reading1,"_independentConductivityReading1Text") test.log(str(independent_Conductivity_Reading1_text.text)) independent_Conductivity_Reading2 =waitForObject(names.o_independentConductivityReadingContainer2_LabelUnitContainer) independent_Conductivity_Reading2_text = utility.findObjectById(independent_Conductivity_Reading2,"_independentConductivityReading2Text") test.log(str(independent_Conductivity_Reading2_text.text)) dialsate_Temperature = waitForObject(names.o_dialsateTemperatureContainer_LabelUnitContainer) dialsate_Temperature_text = utility.findObjectById(dialsate_Temperature, "_dialsateTemperatureText") test.log(str(dialsate_Temperature_text.text)) actualRO_RejectionPercentage = waitForObject(names.o_actualRORejectionPercentageContainer_LabelUnitContainer) actualRO_RejectionPercentage_text = utility.findObjectById(actualRO_RejectionPercentage,"_actualRORejectionPercentageText") test.log(str(actualRO_RejectionPercentage_text.text)) test.endSection() def main(): utils.tstStart(__file__) startApplication(utility.aut("-q")) test.startSection("Verify the water sample, dialysate and Blood sampling ") td.td_operation_mode(TDOpModes.MODE_STAN.value) hemodialysis = waitForObject(names.o_createHDTreatment_TouchRect) hemodialysis_btn = utility.findChildByText(hemodialysis, "Hemodialysis") mouseClick(hemodialysis_btn) td.td_Treatment_Parameters_CreateRx(vRejectionReason =0) td.td_operation_mode(TDOpModes.MODE_PRET.value) set_acid_concentrate() water_sample_tab() test.endSection() dialysate_tab() utils.tstDone()