Index: tst_disinfection/test.py =================================================================== diff -u -r48a93839f9f3aaef88be6c627d43473871f64509 -r3f8003f8a5f8c61fba56c802c5a123d5340b9058 --- tst_disinfection/test.py (.../test.py) (revision 48a93839f9f3aaef88be6c627d43473871f64509) +++ tst_disinfection/test.py (.../test.py) (revision 3f8003f8a5f8c61fba56c802c5a123d5340b9058) @@ -9,82 +9,180 @@ from configuration import utility from dialin.utils.conversions import integer_to_bytearray, float_to_bytearray, short_to_bytearray, unsigned_integer_to_bytearray, integer_to_bit_array, unsigned_short_to_bytearray, unsigned_byte_to_bytearray, unsigned_byte_to_bytearray from dialin.common.hd_defs import HDOpModes, HDOpSubModes +from dateutil.tz._common import ZERO hd_simulator = HDSimulator() dg_simulator = DGSimulator() -def verify_right_navigation_for_chemical_disinfection(): +def verify_right_navigation_for_chemical_disinfection(num_of_instructions): """ The method is used to verify the functionality of the right arrow in the disinfection navigation, as well as the visibility of the two arrows """ test.startSection("Rightward navigation") test.verify(not object.exists(names.o_disinfectChemical_leftImage_Image), "The left navigation arrow should not be present on the first screen of instruction") - for indicator in range(1,num_of_instructions + 1): - verify_bullet_navigation(indicator) - - if indicator != num_of_instructions: + child = object.children(waitForObject(names.o_disinfectChemical_gridSteps_Grid)) + for indicator in range(num_of_instructions): + if child[indicator].id != "_tailStepsRepeater": + verify_bullet_navigation(num_of_instructions, indicator) + if not object.exists(names.o_disinfectChemical_rightImage_Image): + test.log("The right navigation arrow should not be present on the last screen of instruction") + break + mouseClick(waitForObject(names.o_disinfectChemical_rightImage_Image)) - - test.verify(not object.exists(names.o_disinfectChemical_rightImage_Image), "The right navigation arrow should not be present on the last screen of instruction") + test.endSection() -def verify_left_navigation_for_chemical_disinfection(): +def verify_left_navigation_for_chemical_disinfection(num_of_instructions): """ The method is used to verify the functionality of the left arrow in the instruction navigation, as well as the visibility of the two arrows """ test.startSection("Leftward instruction navigation") - test.verify(not object.exists(names.o_PreTreatmentBase_rightImage_Image), "The right navigation arrow should not be present on the last screen of instruction") - for indicator in range(num_of_instructions, 0, -1): - verify_bullet_navigation(indicator) + test.verify(not object.exists(names.o_disinfectChemical_rightImage_Image), "The right navigation arrow should not be present on the last screen of instruction") - if indicator != 1: - mouseClick(waitForObject(names.o_PreTreatmentBase_leftImage_Image)) - - test.verify(not object.exists(names.o_PreTreatmentBase_leftImage_Image), "The left navigation arrow should not be present on the first screen of instruction") + child = object.children(waitForObject(names.o_disinfectChemical_gridSteps_Grid)) + for indicator in range(num_of_instructions, -1, -1): + if child[indicator].id != "_tailStepsRepeater": + verify_bullet_navigation(num_of_instructions, indicator) + if not object.exists(names.o_disinfectChemical_leftImage_Image): + test.log("The left navigation arrow should not be present on the last screen of instruction") + break + + mouseClick(waitForObject(names.o_disinfectChemical_leftImage_Image)) + test.endSection() + +def verify_bullet_navigation(num_of_instructions, indicator): + """ + This method verifies the properties of the bullets present in the instruction navigation screen + """ + test.startSection("Instruction bullet verification for screens " + str(indicator)) + child = object.children(waitForObject(names.o_disinfectChemical_gridSteps_Grid)) + for instruction in range(num_of_instructions): + if child[instruction].id == "_tailStepsRepeater": + continue + bullet_children = object.children(child[instruction]) + bullet_circle_color = bullet_children[0].color.name + bullet_border_color = bullet_children[0].border.color.name + if instruction <= indicator: + test.compare(bullet_circle_color, config.COMPLETE_COLOR) + test.log("The bullet " + str(instruction+1) + " must be a complete bullet") + else: + test.compare(bullet_circle_color, config.INCOMPLETE_COLOR) + test.compare(bullet_border_color,config.CURRENT_COLOR) + test.log("The bullet " + str(instruction+1) + " must be a incomplete bullet") + test.endSection() +def verify_request_rejection_mode(): + """ + Method to verify rejection mode of create custom treatment + """ + test.startSection("Section to verify rejection mode of create custom treatment") + for rejection in range(1, config.NUM_OF_REQUEST_REJECT_REASONS + 1): + hd_simulator.cmd_send_hd_disinfect_response(accepted = 0, reason = rejection) + rejection_message = waitForObjectExists(names.o_disinfectChemical_NotificationBar_NotificationBar) + test.compare(rejection_message.text, config.REJECTION_REASON[rejection], "expected rejection {msg} displayed".format(msg=config.REJECTION_REASON[rejection])) + test.endSection() + + +def verify_confirm_disinfect(): + """ + Method to accept treatment response. + """ + test.startSection("Section to accept treatment response") + hd_simulator.cmd_send_hd_disinfect_response(accepted = 1, reason = 0) + + def verify_disinfection_states(): hd_simulator.cmd_send_hd_disinfection_state(sub_mode = 0, flush_mode = 0, heat_mode = 0, chemical_mode = 1) +def get_dynamic_bullet_count(): + chemical_disinfect_count = 0 + child = object.children(waitForObject(names.o_disinfectChemical_gridSteps_Grid)) + for dynamic_indicator_count in range (len(child)): + if child[dynamic_indicator_count].id != "_tailStepsRepeater": + chemical_disinfect_count+=1 + if chemical_disinfect_count != 0: + return chemical_disinfect_count - - def verify_chemical_disinfect(): + test.startSection("Verification of chemical disinfection.") hd_simulator.cmd_set_hd_operation_mode_data(HDOpModes.MODE_STAN.value,HDOpSubModes.STANDBY_WAIT_FOR_DISINFECT_STATE.value) - mouseclick(names.o_disinfectHome_Chemical_Disinfect) + mouseClick(waitForObject(names.o_disinfectHome_Chemical_Disinfect)) test.compare(waitForObjectExists(names.o_disinfectChemical_Chemical_Disinfect_Text).text, config.CHEMICAL_DISINFECT_TEXT, "Chemical disinfect text should be visible") + test.compare(waitForObjectExists(names.o_disinfectChemical_Chemical_Disinfect_Text_2).text, config.CHEMICAL_DISINFECT_TEXT, "Chemical disinfect indicator should be visible") + test.verify(waitForObjectExists(names.o_disinfectChemical_Chemical_Disinfect_Text_2).font.bold, "Chemical disinfect text from page step indicator should be bold") + test.compare(waitForObjectExists(names.o_disinfectChemical_Disinfection_Text).text, config.DISINFECT_TEXT, "Disinfection text should be visible") + test.verify(not waitForObjectExists(names.o_disinfectChemical_Disinfection_Text).font.bold, "disinfect text from page step indicator should not be bold") + + test.log("verification of instruction navigation from chemical disinfection.") + list_of_bullets = get_dynamic_bullet_count() + test.verify(not waitForObjectExists(names.o_disinfectChemical_confirmButton_TouchRect).enabled, "confirm button must not be active") + verify_right_navigation_for_chemical_disinfection(list_of_bullets) + test.verify(waitForObjectExists(names.o_disinfectChemical_confirmButton_TouchRect).enabled, "confirm button must be active") + verify_left_navigation_for_chemical_disinfection(list_of_bullets) + test.verify(not waitForObjectExists(names.o_disinfectChemical_confirmButton_TouchRect).enabled ,"confirm button must not be active") + for right_arrow in range(list_of_bullets-1): + mouseClick(waitForObject(names.o_disinfectChemical_rightImage_Image)) + test.log("user clicked on tight image arrow for the iteration -> "+str(right_arrow)) + mouseClick(waitForObject(names.o_disinfectChemical_confirmButton_TouchRect)) - # hd_simulator.cmd_send_hd_disinfect_response(accepted = True, reason =1) - payload = integer_to_bytearray(1) - payload += unsigned_integer_to_bytearray(4) - hd_simulator.cmd_send_hd_general_response(message_id=155, accepted=1, reason=1, is_pure_data=False, has_parameters=True, parameters_payload=payload) + verify_request_rejection_mode() + verify_confirm_disinfect() + mouseClick(waitForObject(names.o_disinfectChemical_back_navigation)) + test.endSection() + + + +def verify_heat_disinfect(): + test.startSection("Verification of heat disinfection.") + hd_simulator.cmd_set_hd_operation_mode_data(HDOpModes.MODE_STAN.value,HDOpSubModes.STANDBY_WAIT_FOR_DISINFECT_STATE.value) + mouseClick(waitForObject(names.o_disinfectHome_Heat_Disinfect)) - snooze(5) - hd_simulator.cmd_send_hd_disinfection_state(sub_mode = 0, flush_mode = 0, heat_mode = 0, chemical_mode = 1) - snooze(5) - dg_simulator.cmd_send_dg_disinfect_progress_time_flush(total = 120, countdown = 45) - test.log("User navigated to chemical disinfect section") + utility.verify_page_step_indicator_for_disinfect(config.DISINFECT_TREATMENT_ID, 1, config.HEAT_DISINFECT_TREATMENT_SCREENS) + + test.compare(waitForObjectExists(names.o_disinfectChemical_Chemical_Disinfect_Text).text, config.CHEMICAL_DISINFECT_TEXT, "Chemical disinfect text should be visible") + test.compare(waitForObjectExists(names.o_disinfectChemical_Chemical_Disinfect_Text_2).text, config.CHEMICAL_DISINFECT_TEXT, "Chemical disinfect indicator should be visible") + test.verify(waitForObjectExists(names.o_disinfectChemical_Chemical_Disinfect_Text_2).font.bold, "Chemical disinfect text from page step indicator should be bold") + test.compare(waitForObjectExists(names.o_disinfectChemical_Disinfection_Text).text, config.DISINFECT_TEXT, "Disinfection text should be visible") + test.verify(not waitForObjectExists(names.o_disinfectChemical_Disinfection_Text).font.bold, "disinfect text from page step indicator should not be bold") + -def verify_heat_disinfect(): - pass + test.log("verification of instruction navigation from chemical disinfection.") + list_of_bullets = get_dynamic_bullet_count() + test.verify(not waitForObjectExists(names.o_disinfectChemical_confirmButton_TouchRect).enabled, "confirm button must not be active") + verify_right_navigation_for_chemical_disinfection(list_of_bullets) + test.verify(waitForObjectExists(names.o_disinfectChemical_confirmButton_TouchRect).enabled, "confirm button must be active") + verify_left_navigation_for_chemical_disinfection(list_of_bullets) + test.verify(not waitForObjectExists(names.o_disinfectChemical_confirmButton_TouchRect).enabled ,"confirm button must not be active") + + for right_arrow in range(list_of_bullets-1): + mouseClick(waitForObject(names.o_disinfectChemical_rightImage_Image)) + test.log("user clicked on tight image arrow for the iteration -> "+str(right_arrow)) + mouseClick(waitForObject(names.o_disinfectChemical_confirmButton_TouchRect)) + + verify_request_rejection_mode() + verify_confirm_disinfect() + + test.endSection() + def verify_water_flush(): pass @@ -109,6 +207,22 @@ dg_simulator.cmd_send_dg_disinfect_progress_time_flush(self, total: int, countdown: int) dg_simulator.cmd_send_dg_disinfect_progress_time_heat(self, total: int, countdown: int) + + + + # hd_simulator.cmd_send_hd_disinfect_response(accepted = True, reason =1) + #payload = integer_to_bytearray(1) + #payload += unsigned_integer_to_bytearray(4) + #hd_simulator.cmd_send_hd_general_response(message_id=155, accepted=1, reason=1, is_pure_data=False, has_parameters=True, parameters_payload=payload) + + + + + snooze(5) + #hd_simulator.cmd_send_hd_disinfection_state(sub_mode = 0, flush_mode = 0, heat_mode = 0, chemical_mode = 1) + #snooze(5) + #dg_simulator.cmd_send_dg_disinfect_progress_time_flush(total = 120, countdown = 45) + """ utils.waitForGUI(2)