# -*- coding: utf-8 -*- ## # Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. # copyright # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, # IN PART OR IN WHOLE, # WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # file tst_cloud_sync_hd_opmodes # date 2022/07/08 # author Shweta Policepatil # # # # NOTE: # This test verifies the cloud sync - tst_cloud_sync_hd_opmode. import names from dialin.ui.hd_simulator import HDSimulator from dialin.ui import utils from configuration import utility from configuration import config from dialin.common.hd_defs import HDOpModes, HDOpSubModes hd_simulator = HDSimulator() MESSAGE_FAULT_MODE = '1639391827,1,0,1006,2,0,0' MESSAGE_SERVICE_MODE = '1639391827,1,0,1006,2,1,0' MESSAGE_INIT_MODE = '1639391827,1,0,1006,2,2,0' MESSAGE_STAND_BY_MODE = '1639391827,1,0,1006,2,3,0' MESSAGE_TPAR_MODE = '1639391827,1,0,1006,2,4,0' MESSAGE_PRETREATMENT_MODE = '1639391827,1,0,1006,2,5,0' MESSAGE_PRETREATMENT_MODE = '1639391827,1,0,1006,2,6,0' MESSAGE_POST_TREATMENT_MODE = '1639391827,1,0,1006,2,7,0' MESSAGE_ILLEGAL_TRANSITION_MODE = '1639391827,1,0,1006,2,8,0' DEVICE_CREDENTIALS_RESPONSE = '1639391827,1,0,1004,1,/tmp/credentials/' def navigate_to_hd_opmodes(): """ Method to navigate different hd opmodes to verify message id's logged in cloudsync """ test.startSection("Navigating to different hd opmodes to verify message id's") test.log("Fault mode") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_FAUL.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) utils.waitForGUI(1) hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_INIT.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) utils.waitForGUI(1) test.log("Standby mode") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_STAN.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) utils.waitForGUI(1) test.log("Treatment mode") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_TPAR.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) utils.waitForGUI(1) test.log("Pre- Treatment mode") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_PRET.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) utils.waitForGUI(1) test.log("Treatment mode") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_TREA.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) utils.waitForGUI(1) test.log("Post treatment Screen") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_POST.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) utils.waitForGUI(1) test.log("Service Screen") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_SERV.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) utils.waitForGUI(1) test.log("Illegal trasition") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_NLEG.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) mouseClick(waitForObjectExists(names.device_settings_screen)) test.log ("Service mode") test.endSection() def verify_code_from_treatment_response(): """ This function is used for verify the code text from treatment log. """ hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_POST.value, sub_mode=PostTreatmentStates.HD_POST_TREATMENT_PATIENT_DISCONNECTION_STATE.value) for indicator in range(1, POST_TREATMENT_INSTRUCTION_COUNT, 1): if indicator != POST_TREATMENT_INSTRUCTION_COUNT: mouseClick(waitForObject(names.o_patient_Disconnection_right_arrow)) utils.waitForGUI(2) mouseClick(names.o_patientDisconnectionConfirm_CONFIRM_Text) message_text = MESSAGE_FAULT_MODE.split(',') utils.waitForGUI(3) #delay for fetching the effect text_code_label = str(waitForObjectExists(names.o_treatmentReviewConfirm_Code_Tx_code_Label).text) test.compare(message_text[5], text_code_label.split(': ')[1], "CS2UI message should be verified") def get_data_from_cloud_sync_input_file(message): """ This function is capable to write message into cloud sync folder. Through this method file reader act as a handler and it will write custom messages into {current_date}_out.buf @input: (string) message -expected message to be write on out.buf file. """ cloud_out_log = utility.get_cloud_sync_input_file() with open(cloud_out_log, "r") as filereader: filereader.write(message) utils.waitForGUI(5) def verify_log_response(actual_cloudsync_data, expected_cloudsync_data): test.startSection("Verification of cloud response for code %s" %actual_cloudsync_data[3]) expected_cloudsync_data = expected_cloudsync_data.split(',') for index in (0, 2, 3, 4, 5): test.compare(expected_cloudsync_data[index], actual_cloudsync_data[index], "cloud sync data %s is verified" %expected_cloudsync_data[index]) test.endSection() def main(): utility.append_cloudsync_credentials_file() utils.tstStart(__file__) startApplication(config.AUT_NAME) utils.waitForGUI(1.5) navigate_to_hd_opmodes() utility.get_cloud_sync_input_file() test.log("input.buf") utility.retrive_log_data() test.log("file created") utils.tstDone()