Index: tst_standbymode/test.py =================================================================== diff -u -r03b5230f7cecbb728de9357e4582cf381b24cba2 -ra9219e9ca0692311f23f60aa7c9b574fb449d3e6 --- tst_standbymode/test.py (.../test.py) (revision 03b5230f7cecbb728de9357e4582cf381b24cba2) +++ tst_standbymode/test.py (.../test.py) (revision a9219e9ca0692311f23f60aa7c9b574fb449d3e6) @@ -7,47 +7,45 @@ # IN PART OR IN WHOLE, # WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # -# file tst_In_treatment -# date 2020/01/11 -# author Joseph Varghese -# +# file tst_standbymode +# date 2022/04/01 +# author Joseph varghese +# author Amol Shinde +# author Bhavana Savanth # NOTE: # This test contradicts verification of standbymode. -import datetime import names +import datetime from time import sleep from dialin.ui import utils +from configuration import config,utility from dialin.ui.hd_simulator import HDSimulator from configuration import config from builtins import int as pyInt +from dialin.common.hd_defs import HDOpModes +hd_simulator = HDSimulator() +MORNING_MIN = "00" +MORNING_MAX = "12" + GOODMORNING_START_TIME_SEC = 0 GOODEVENING_START_TIME_SEC = 43200 def get_current_time(): """ Tests to get current time. - @return: current time in seconds """ - now = datetime.datetime.now() - current_time = now.strftime("%H:%M:%S") - hours, minutes, seconds = current_time.split(':') - time_in_seconds = datetime.timedelta(hours = pyInt(hours), - minutes = pyInt(minutes), - seconds = pyInt(seconds)) - total_seconds = time_in_seconds.total_seconds() - return total_seconds - - -def verification_of_create_treatment_text(): + current_time = utility.get_current_date_and_time("%H") + return current_time + +def verify_create_treatment_text(): """ Tests for verification of create treatment text. - @return: N/A """ standby_text = waitForObject(names.o_standby_page) @@ -56,36 +54,75 @@ test.compare(child.text, "CREATE TREATMENT") -def verification_of_welcome_text_on_standby_mode(current_time): +def verify_welcome_text_on_standby_mode(current_time): """ Tests to verify welcome text based on current time. - @return: current time in seconds """ standby_text = waitForObject(names.o_standby_page) child = object.children(standby_text)[0] - if current_time >= config.GOODMORNING_START_TIME_SEC and \ - current_time <= config.GOODEVENING_START_TIME_SEC: - test.compare(child.text, "Good Morning") + print(str(current_time)) + if current_time >= MORNING_MIN and current_time < MORNING_MAX: + test.xcompare(child.text, "Good Morning") else: - test.compare(child.text, "Good Evening") + test.xcompare(child.text, "Good Evening") +def event_analysis_for_create_treatment_button(): + """ + Tests to verify binaries for create treatment button upon click + """ + mouseClick(waitForObject(names.o_MainHome_Create_Treatment_Button)) + + #message = utility.cmd_set_create_treatment_click_event(response = True) + #event_binary = utility.ui_all_publication_handler(message) + + #test.compare(config.CREATE_TREATMENT_BUTTON_ACTIVE, str(event_binary), "binaries obtained during event-> create treatment button click should be expected") + + +def ui_all_publication_handler(message: dict) -> None: + """ + This function is the default handler of the ui received messages which only prints out the received message + - This function can be used as an example. + - Be careful that there is only one ui publication method + and it will be overwritten on each call to the function set_ui_all_publication of the HDSimulator. + Look into the _init_loader of the Simulator class for example on how to register. + self.interface.hd.set_ui_all_publication(ui_all_publication_handler) + - This function is filtering the two message ID: + MsgIds.MSG_ID_UI_CHECK_IN.value, + MsgIds.MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK.value + for the simplicity of the printed message and as example of how to filter. + That filter can obviously be removed. + + @param message: the ui received message + @return: None + """ + exception_msg_id = { + MsgIds.MSG_ID_UI_CHECK_IN.value, + MsgIds.MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK.value + } + msg_id = DenaliMessage.get_message_id(message) + if msg_id in exception_msg_id: + return + + test.log(">", DenaliCanMessenger.convert_message_to_string(message)) + + def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) - - hd = HDSimulator() - hd.cmd_send_power_on_self_test_version_request() - hd.cmd_send_hd_operation_mode(3) + hd_simulator.cmd_send_power_on_self_test_version_request() + hd_simulator.cmd_send_hd_operation_mode(HDOpModes.MODE_STAN.value) + hd_simulator.set_ui_all_publication(ui_all_publication_handler) + event_analysis_for_create_treatment_button() current_time = get_current_time() - verification_of_welcome_text_on_standby_mode(current_time) - sleep(0.5) - verification_of_create_treatment_text() + verify_welcome_text_on_standby_mode(current_time) + verify_create_treatment_text() utils.tstDone() + \ No newline at end of file