Index: tst_main_treatment_heparin/test.py =================================================================== diff -u -r730d9a0dcfe6a4f89942e4c5f5d0cb49c3770fc3 -reef86539ca04b1ee244012f28ec7662bb1c1819f --- tst_main_treatment_heparin/test.py (.../test.py) (revision 730d9a0dcfe6a4f89942e4c5f5d0cb49c3770fc3) +++ tst_main_treatment_heparin/test.py (.../test.py) (revision eef86539ca04b1ee244012f28ec7662bb1c1819f) @@ -11,7 +11,7 @@ from configuration import config, utility from dialin.ui import utils from dialin.ui.hd_simulator import HDSimulator -from configuration.utility import expected_heparin_value +from configuration.utility import expected_heparin_value, rejection_msg from dialin.ui.utils import waitForGUI from configuration.config import REJECTION_REASON from urllib3.util.request import ACCEPT_ENCODING @@ -103,8 +103,8 @@ test.compare(str(waitForObjectExists(names.o_state_one_text).text), config.HEPARIN_STOP_TEXT, utility.msg("Notification Message should be {}".format(config.HEPARIN_STOP_TEXT))) utils.waitForGUI(1) - #constants_for_cumulative_value() - #heparin_pause_resume_states() + constants_for_cumulative_value() + heparin_pause_resume_states() test.log("Verifying Heparin State 5 - HEPARIN_STATE_COMPLETED") hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 5, @@ -127,30 +127,7 @@ test.log("Verifying Notification Message") test.compare(str(waitForObjectExists(names.o_state6_heparin_state_empty_text).text), config.HEPARIN_SYRINGE_EMPTY_TEXT, utility.msg("Notification Message should be {}".format(config.HEPARIN_SYRINGE_EMPTY_TEXT))) utils.waitForGUI(1) - -# def heparin_pause_resume_states(): -# """ -# Verifying pause/resume delivery when HEPARIN DELIVERY button is active or deactive using heparin states -# HEPARIN STATE 2 -> HEPARIN_STATE_PAUSED -# HEPARIN STATE 4 -> HEPARIN_STATE_DISPENSING -# """ -# test.startSection("Verifying Heparin State ->2 HEPARIN_STATE_PAUSED") -# hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 2, -# 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_state2_heparin_state_paused_text).text),config.HEPARIN_RESUME_DELIVERY_TEXT, utility.msg("Heparin Resume Delivery Text should be {}".format(config.HEPARIN_RESUME_DELIVERY_TEXT))) -# test.compare( waitForObjectExists(names.o_state2_heparin_state_paused_text).enabled, True, utility.msg("Resume Delivery Button is enabled")) -# hd_simulator.cmd_set_heparin_pause_resume_response(accepted = 0, reason = 0) -# verify_rejection_msg_id(True) -# hd_simulator.cmd_set_heparin_pause_resume_response(accepted = 0, reason = 1) -# -# -# test.compare(str(waitForObjectExists(names.o_state4_heparin_state_paused_text).text),config.HEPARIN_PAUSE_DELIVERY_TEXT, utility.msg("Heparin Pause Delivery Text should be {}".format(config.HEPARIN_RESUME_DELIVERY_TEXT))) -# test.compare( waitForObjectExists(names.o_state4_heparin_state_paused_text).enabled, True, utility.msg("Pause Delivery Button is enabled")) -# verify_rejection_msg_id(False) -# -# test.endSection() - + def heparin_pause_resume_states(): """ Verifying pause/resume delivery when HEPARIN DELIVERY button is active or deactive using heparin states @@ -195,89 +172,88 @@ def test_case_scenario(): - "Scenario to test states and rejection messages" + """ + Method to test current states and rejection messages + """ + + 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) - hd_simulator.cmd_set_heparin_pause_resume_response(accepted=0, 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("Rejected") + + 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") + test.log("Accepted the state") hd_simulator.cmd_set_heparin_pause_resume_response(accepted=0, reason=2) - 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("Rejected") - + 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")) -# 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")) -# verify_rejection_msg_id(False) - hd_simulator.cmd_set_heparin_pause_resume_response(accepted=1, reason=2) + + 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")) - 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")) -# - hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 5, - 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=1, reason=2) - test.compare(str(waitForObjectExists(names.o_state0_heparin_delivery_Off_text).text), config.HEPARIN_DELIVERY_OFF_TEXT, utility.msg("Heparin Delivery Text should be {}".format(config.HEPARIN_DELIVERY_TEXT))) - test.compare((waitForObjectExists(names.o_state0_heparin_delivery_Off_text)).enabled, False, utility.msg("Heparin Delivery should be disabled")) - test.log("Again change state reject and Accept") - hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 5, - 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=0, reason=2) - test.compare(str(waitForObjectExists(names.o_state0_heparin_delivery_Off_text).text), config.HEPARIN_DELIVERY_OFF_TEXT, utility.msg("Heparin Delivery Text should be {}".format(config.HEPARIN_DELIVERY_TEXT))) - test.compare((waitForObjectExists(names.o_state0_heparin_delivery_Off_text)).enabled, False, utility.msg("Heparin Delivery should be disabled")) - test.log("Accepted with reason") + 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")) + + 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 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_pause_resume_states() test_case_scenario() verify_the_rejection_msg()