Index: tst_main_treatment_heparin/test.py =================================================================== diff -u -r9bc095139a979884568d711d8bee082507850130 -r7b9eba47434a066266afbae35ee8c2ec2fe394aa --- tst_main_treatment_heparin/test.py (.../test.py) (revision 9bc095139a979884568d711d8bee082507850130) +++ tst_main_treatment_heparin/test.py (.../test.py) (revision 7b9eba47434a066266afbae35ee8c2ec2fe394aa) @@ -20,6 +20,15 @@ HIGHER_RANGE = 20 STEP_VALUE = 1 LOWER_RANGE = 0 +HEPARIN_BUTTON_STATES = {0: "OFF", 1: "HEPARIN DELIVERY", 2: "RESUME DELIVERY", + 3: "HEPARIN DELIVERY", 4: "PAUSE DELIVERY", + 5: "OFF", 6: "HEPARIN DELIVERY"} +HEPARIN_STATE_MSGS = {"STATE_0_OFF_MESSAGE": "", "STATE_1_HEPARIN DELIVERY_MESSAGE": "Delivery Stopped", + "STATE_2_RESUME DELIVERY_MESSAGE": "Delivery Paused", + "STATE_3_HEPARIN DELIVERY_MESSAGE": "Bolus Active", + "STATE_4_PAUSE DELIVERY_MESSAGE": "Dispensing Active", + "STATE_5_OFF_MESSAGE": "Maximum Cumulative Heparin Volume Delivered", + "STATE_6_HEPARIN DELIVERY_MESSAGE": "Syringe Empty"} hd_simulator = HDSimulator() def verification_of_cumulative_value(expected_cumulative_value): @@ -155,19 +164,14 @@ test.log("Heparin delivery is in dispensing state") test.endSection() -def verify_the_rejection_msg(): +def verify_the_rejection_msg(reason_id): """ Method to verify rejection messages """ test.startSection("Verifying Rejection Messages") - hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 4, - rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, - treatment_end_state=0, treatment_stop_state= 0, dialysis_state= 0) - for reason_id in range(1, config.NUM_OF_REQUEST_REJECT_REASONS+1): - hd_simulator.cmd_set_heparin_pause_resume_response(accepted=0, reason=reason_id) - rejection_msg = waitForObjectExists(utility.rejection_msg(text=config.REJECTION_REASON[reason_id])) - test.compare(rejection_msg.text, config.REJECTION_REASON[reason_id], utility.msg("The rejection message should be {}".format(config.REJECTION_REASON[reason_id]))) + rejection_msg = waitForObjectExists(utility.rejection_msg(text=config.REJECTION_REASON[reason_id])) + test.compare(rejection_msg.text, config.REJECTION_REASON[reason_id], utility.msg("The rejection message should be {}".format(config.REJECTION_REASON[reason_id]))) test.endSection() def verify_rejection_messages_for_heparin_states(): @@ -177,85 +181,40 @@ """ test.startSection("Verifying test case scenario for rejection and acceptance in current state") - hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 4, - rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, - treatment_end_state=0, treatment_stop_state= 0, dialysis_state= 0) - test.compare(str(waitForObjectExists(names.o_state4_heparin_state_dispensing_text).text), config.HEPARIN_PAUSE_DELIVERY_TEXT, utility.msg("Heparin Pause Delivery Text should be {}".format(config.HEPARIN_PAUSE_DELIVERY_TEXT))) - test.compare( waitForObjectExists(names.o_state4_heparin_state_dispensing_text).enabled , True, utility.msg("Pause Delivery Button is enabled")) - - hd_simulator.cmd_set_heparin_pause_resume_response(accepted=0, reason=1) - rejection_msg = waitForObjectExists(utility.rejection_msg(text=config.REJECTION_REASON[1])) - test.compare(rejection_msg.text, config.REJECTION_REASON[1], utility.msg("The rejection message should be {}".format(config.REJECTION_REASON[1]))) - test.log(str(rejection_msg.text),"Rejected the state") - - hd_simulator.cmd_set_heparin_pause_resume_response(accepted=1, reason=1) - test.compare(str(waitForObjectExists(names.o_state4_heparin_state_dispensing_text).text), config.HEPARIN_PAUSE_DELIVERY_TEXT, utility.msg("Heparin Pause Delivery Text should be {}".format(config.HEPARIN_PAUSE_DELIVERY_TEXT))) - test.compare( waitForObjectExists(names.o_state4_heparin_state_dispensing_text).enabled , True, utility.msg("Pause Delivery Button is enabled")) - test.log("Accepted the state") - - hd_simulator.cmd_set_heparin_pause_resume_response(accepted=0, reason=2) - rejection_msg = waitForObjectExists(utility.rejection_msg(text=config.REJECTION_REASON[2])) - test.compare(rejection_msg.text, config.REJECTION_REASON[2], utility.msg("The rejection message should be {}".format(config.REJECTION_REASON[2]))) - test.log(str(rejection_msg.text),"Rejected the state") - - #changing the state - hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 3, - rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, - treatment_end_state=0, treatment_stop_state= 0, dialysis_state= 0) - test.compare(str(waitForObjectExists(names.o_state1_heparin_delivery_text).text), config.HEPARIN_DELIVERY_TEXT, utility.msg("Heparin Delivery Text should be {}".format(config.HEPARIN_DELIVERY_TEXT))) - test.compare((waitForObjectExists(names.o_state1_heparin_delivery_text)).enabled, False, utility.msg("Heparin Delivery should be disabled")) - - hd_simulator.cmd_set_heparin_pause_resume_response(accepted=0, reason=16) - rejection_msg = waitForObjectExists(utility.rejection_msg(text=config.REJECTION_REASON[16])) - test.compare(rejection_msg.text, config.REJECTION_REASON[16], utility.msg("The rejection message should be {}".format(config.REJECTION_REASON[1]))) - test.log(str(rejection_msg.text),"Rejected the state") - - test.compare(str(waitForObjectExists(names.o_state1_heparin_delivery_text).text), config.HEPARIN_DELIVERY_TEXT, utility.msg("Heparin Delivery Text should be {}".format(config.HEPARIN_DELIVERY_TEXT))) - test.compare((waitForObjectExists(names.o_state1_heparin_delivery_text)).enabled, False, utility.msg("Heparin Delivery should be disabled")) - - hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 6, - rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, - treatment_end_state=0, treatment_stop_state= 0, dialysis_state= 0) - test.compare(str(waitForObjectExists(names.o_state6_heparin_state_empty_text).text), config.HEPARIN_SYRINGE_EMPTY_TEXT, utility.msg("Heparin Delivery Text should be {}".format(config.HEPARIN_DELIVERY_TEXT))) - test.compare((waitForObjectExists(names.o_state6_heparin_state_empty_text)).enabled, True, utility.msg("Heparin Delivery should be disabled")) - - hd_simulator.cmd_set_heparin_pause_resume_response(accepted=1, reason=0) - test.log("Changed the state and accepted") - test.compare(str(waitForObjectExists(names.o_state6_heparin_state_empty_text).text), config.HEPARIN_SYRINGE_EMPTY_TEXT, utility.msg("Heparin Delivery Text should be {}".format(config.HEPARIN_DELIVERY_TEXT))) - test.compare((waitForObjectExists(names.o_state6_heparin_state_empty_text)).enabled, True, utility.msg("Heparin Delivery should be disabled")) - + for reason_id in range(1, (config.NUM_OF_REQUEST_REJECT_REASONS)): + for state_id, state in HEPARIN_BUTTON_STATES.items(): + hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state=state_id, + rinseback_state=0, recirculate_state=0, blood_prime_state=0, + treatment_end_state=0, treatment_stop_state=0, dialysis_state=0) + test.compare(str(waitForObjectExists(utility.expected_heparin_value(state)).text), state, utility.msg("{} text should be displayed".format(state))) + hd_simulator.cmd_set_heparin_pause_resume_response(accepted=0, reason=reason_id) + verify_the_rejection_msg(reason_id) + hd_simulator.cmd_set_heparin_pause_resume_response(accepted=1, reason=reason_id) + test.log("Verifying rejection message {} is not displayed".format(config.REJECTION_REASON[reason_id])) + test.log("Verifying the current state of heparin button") + test.compare(str(waitForObjectExists(utility.expected_heparin_value(state)).text), state, utility.msg("{} text should be displayed".format(state))) + msg = HEPARIN_STATE_MSGS["STATE_"+str(state_id)+"_"+state+"_MESSAGE"] + test.compare(waitForObjectExists(utility.expected_heparin_value(msg)).text, msg, utility.msg("{} text should be displayed".format(msg))) + hd_simulator.cmd_set_heparin_pause_resume_response(accepted=0, reason=reason_id+1) + verify_the_rejection_msg(reason_id=reason_id+1) + #changing the state + hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state=state_id+1, + rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, + treatment_end_state=0, treatment_stop_state= 0, dialysis_state= 0) + if state_id == 6: + break + else: + test.compare(str(waitForObjectExists(utility.expected_heparin_value(HEPARIN_BUTTON_STATES[state_id+1])).text), HEPARIN_BUTTON_STATES[state_id+1], utility.msg("{} text should be displayed".format(HEPARIN_BUTTON_STATES[state_id+1]))) + msg = HEPARIN_STATE_MSGS["STATE_"+str(state_id+1)+"_"+HEPARIN_BUTTON_STATES[state_id+1]+"_MESSAGE"] + test.compare(waitForObjectExists(utility.expected_heparin_value(msg)).text, msg, utility.msg("{} text should be displayed".format(msg))) test.endSection() -# def verify_rejection_msg_id(accept_msg_id): -# """ -# Method to verify rejection messages -# -# """ -# if accept_msg_id == False: -# -# test.startSection("Verifying Rejection Messages") -# hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 4, -# rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, -# treatment_end_state=0, treatment_stop_state= 0, dialysis_state= 0) -# for reason_id in range(1, config.NUM_OF_REQUEST_REJECT_REASONS+1): -# hd_simulator.cmd_set_heparin_pause_resume_response(accepted=accept_msg_id, reason=reason_id) -# rejection_msg = waitForObjectExists(utility.rejection_msg(text=config.REJECTION_REASON[reason_id])) -# test.compare(rejection_msg.text, config.REJECTION_REASON[reason_id], utility.msg("The rejection message should be {}".format(config.REJECTION_REASON[reason_id]))) -# test.endSection() -# else: -# hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 4, -# rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, -# treatment_end_state=0, treatment_stop_state= 0, dialysis_state= 0) -# hd_simulator.cmd_set_heparin_pause_resume_response(accepted=accept_msg_id, reason=0) -# test.log(config.REJECTION_REASON[0]) - def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) - heparin_stop_states_in_main_treatment() +# heparin_stop_states_in_main_treatment() verify_rejection_messages_for_heparin_states() - verify_the_rejection_msg() utils.tstDone() \ No newline at end of file