Index: shared/scripts/configuration/config.py =================================================================== diff -u -re620a9fd664c96a736c0d7ca2ffe03d98a913189 -r1b298b2e80e20d600e2dab95b055c878c2521c83 --- shared/scripts/configuration/config.py (.../config.py) (revision e620a9fd664c96a736c0d7ca2ffe03d98a913189) +++ shared/scripts/configuration/config.py (.../config.py) (revision 1b298b2e80e20d600e2dab95b055c878c2521c83) @@ -31,6 +31,7 @@ BLOOD_PRIMING_TEXT = "Blood Priming" SALINE_UNIT = "mL" BLOOD_PRIMING_DEFAULT_VALUE = "0 mL" + EPOCH_INDEX = 0 SEQUENCE_INDEX = 1 CRC_INDEX = 2 @@ -39,4 +40,6 @@ OPMODE_INDEX = 5 SUBMODE = 6 +HD_OPMODES_MSG_PARAMETER_LEN = 7 +HD_OPMODES_CREDENTIAL_PARAMETER_LEN = 6 Index: shared/scripts/configuration/utility.py =================================================================== diff -u -re620a9fd664c96a736c0d7ca2ffe03d98a913189 -r1b298b2e80e20d600e2dab95b055c878c2521c83 --- shared/scripts/configuration/utility.py (.../utility.py) (revision e620a9fd664c96a736c0d7ca2ffe03d98a913189) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 1b298b2e80e20d600e2dab95b055c878c2521c83) @@ -25,13 +25,21 @@ -def get_current_date_and_time(date_format='%Y/%b/%d - %H:%M:%S'): - +def get_current_date_and_time(date_format='%Y/%m/%d - %H:%M:%S'): ##doc string need to be added + """ + Method to get current date and time. + @input date_format (str) - format of date to be retrieved. + @return (str) - date in specified format. + """ date = datetime.now() return str(date.strftime(date_format)) def append_cloudsync_credentials_file(): - + """ + This function is the handler for getting file from log folder. + Application log file is automatically created on '/home/denali/Desktop/sd-card/cloudsync/ {current_date}_out.log' + @return latest_file - (string) returns latest file that append on log folder from sd-data + """ try: os.makedirs(CLOUD_CREDENTIALS_LOCATION, exist_ok = True) test.log("Directory created successfully") Index: tst_cloud_sync_hd_opmodes/test.py =================================================================== diff -u -raa8fc1d9dd07fd00c14321863c0d090c3c887503 -r1b298b2e80e20d600e2dab95b055c878c2521c83 --- tst_cloud_sync_hd_opmodes/test.py (.../test.py) (revision aa8fc1d9dd07fd00c14321863c0d090c3c887503) +++ tst_cloud_sync_hd_opmodes/test.py (.../test.py) (revision 1b298b2e80e20d600e2dab95b055c878c2521c83) @@ -39,131 +39,129 @@ def verify_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") + Method is used to navigate to different hd opmodes and verify message id's + @message_id 1006 - to send device state from UI2CS + @message_id 1004 - to send device credentials from UI2CS + """ test.startSection("Verifying message id, opmode, submode for intialisation screen") 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("Initial mode") - actual_inp_buf_data = utility.retrive_log_data(2) + retrive_log_data_lines = 2 + actual_inp_buf_data = utility.retrive_log_data(retrive_log_data_lines) test.log(str(actual_inp_buf_data[0])) verify_log_response(actual_inp_buf_data[0],MESSAGE_INIT_MODE) - verify_log_response_credentials(actual_inp_buf_data[1],DEVICE_CREDENTIALS_RESPONSE) + verify_log_response(actual_inp_buf_data[1],DEVICE_CREDENTIALS_RESPONSE) test.endSection() test.startSection("Verifying message id, opmode, submode for Standby mode screen") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_STAN.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) - utils.waitForGUI(2) + utils.waitForGUI(1) test.log("Stand By mode") - actual_inp_buf_data = utility.retrive_log_data(4) + retrive_log_data_lines = 4 + actual_inp_buf_data = utility.retrive_log_data(retrive_log_data_lines) test.log(str(actual_inp_buf_data[0])) verify_log_response(actual_inp_buf_data[0],MESSAGE_STAND_BY_MODE) - verify_log_response_credentials(actual_inp_buf_data[1],DEVICE_CREDENTIALS_RESPONSE) + verify_log_response(actual_inp_buf_data[1],DEVICE_CREDENTIALS_RESPONSE) test.endSection() test.startSection("Verifying message id, opmode, submode for Treatment parameter mode screen") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_TPAR.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) - utils.waitForGUI(2) + utils.waitForGUI(1) test.log("Treatment parameter mode") - actual_inp_buf_data = utility.retrive_log_data(6) + retrive_log_data_lines = 6 + actual_inp_buf_data = utility.retrive_log_data(retrive_log_data_lines) test.log(str(actual_inp_buf_data[0])) verify_log_response(actual_inp_buf_data[0],MESSAGE_TPAR_MODE) - verify_log_response_credentials(actual_inp_buf_data[1],DEVICE_CREDENTIALS_RESPONSE) + verify_log_response(actual_inp_buf_data[1],DEVICE_CREDENTIALS_RESPONSE) test.endSection() test.startSection("Verifying message id, opmode, submode for Pre -treatment mode screen") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_PRET.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) - utils.waitForGUI(2) + utils.waitForGUI(1) test.log("Pre - Treatment mode") - actual_inp_buf_data = utility.retrive_log_data(8) + retrive_log_data_lines = 8 + actual_inp_buf_data = utility.retrive_log_data(retrive_log_data_lines) test.log(str(actual_inp_buf_data[0])) verify_log_response(actual_inp_buf_data[0],MESSAGE_PRETREATMENT_MODE) - verify_log_response_credentials(actual_inp_buf_data[1],DEVICE_CREDENTIALS_RESPONSE) + verify_log_response(actual_inp_buf_data[1],DEVICE_CREDENTIALS_RESPONSE) test.endSection() test.startSection("Verifying message id, opmode, submode for Treatment mode screen") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_TREA.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) - utils.waitForGUI(2) + utils.waitForGUI(1) test.log("Treatment mode") - actual_inp_buf_data = utility.retrive_log_data(10) + retrive_log_data_lines = 10 + actual_inp_buf_data = utility.retrive_log_data(retrive_log_data_lines) test.log(str(actual_inp_buf_data[0])) verify_log_response(actual_inp_buf_data[0],MESSAGE_TREATMENT_MODE) - verify_log_response_credentials(actual_inp_buf_data[1],DEVICE_CREDENTIALS_RESPONSE) + verify_log_response(actual_inp_buf_data[1],DEVICE_CREDENTIALS_RESPONSE) test.endSection() test.startSection("Verifying message id, opmode, submode for Post treatment mode screen") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_POST.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) - utils.waitForGUI(2) + utils.waitForGUI(1) test.log("Post - treatment mode") - actual_inp_buf_data = utility.retrive_log_data(12) + retrive_log_data_lines = 12 + actual_inp_buf_data = utility.retrive_log_data(retrive_log_data_lines) test.log(str(actual_inp_buf_data[0])) verify_log_response(actual_inp_buf_data[0],MESSAGE_POST_TREATMENT_MODE) - verify_log_response_credentials(actual_inp_buf_data[1],DEVICE_CREDENTIALS_RESPONSE) + verify_log_response(actual_inp_buf_data[1],DEVICE_CREDENTIALS_RESPONSE) test.endSection() test.startSection("Verifying message id, opmode, submode for Service mode screen") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_SERV.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) - utils.waitForGUI(2) + utils.waitForGUI(1) test.log("Service mode") - actual_inp_buf_data = utility.retrive_log_data(14) + retrive_log_data_lines = 14 + actual_inp_buf_data = utility.retrive_log_data(retrive_log_data_lines) test.log(str(actual_inp_buf_data[0])) verify_log_response(actual_inp_buf_data[0],MESSAGE_SERVICE_MODE) - verify_log_response_credentials(actual_inp_buf_data[1],DEVICE_CREDENTIALS_RESPONSE) + verify_log_response(actual_inp_buf_data[1],DEVICE_CREDENTIALS_RESPONSE) test.endSection() test.startSection("Verifying message id, opmode, submode for Illegal transition screen") 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)) - utils.waitForGUI(2) + utils.waitForGUI(1) test.log ("Illegal Transition") - actual_inp_buf_data = utility.retrive_log_data(16) + retrive_log_data_lines = 16 + actual_inp_buf_data = utility.retrive_log_data(retrive_log_data_lines) test.log(str(actual_inp_buf_data[0])) verify_log_response(actual_inp_buf_data[0],MESSAGE_ILLEGAL_TRANSITION_MODE) - verify_log_response_credentials(actual_inp_buf_data[1],DEVICE_CREDENTIALS_RESPONSE) + verify_log_response(actual_inp_buf_data[1],DEVICE_CREDENTIALS_RESPONSE) test.endSection() - - test.endSection() + def verify_log_response(actual_cloudsync_data, expected_cloudsync_data): """ This function is used for verifying the expected and actual cloud-sync log data. """ test.startSection("Verification of cloud response for code %s" %actual_cloudsync_data[config.CODE_INDEX]) expected_cloudsync_data = expected_cloudsync_data.split(',') current_epoch_value = time.time() - + epoch_value_status = utility.get_epoch_value_consistancy(current_epoch_value, actual_cloudsync_data[config.EPOCH_INDEX]) test.verify(epoch_value_status, "epoch value should be in range and it is verified") - for index in (config.CRC_INDEX, config.CODE_INDEX, config.PARAMETER_COUNT, config.OPMODE_INDEX, config.SUBMODE): - test.compare(expected_cloudsync_data[index], actual_cloudsync_data[index], "cloud sync data %s is verified" %expected_cloudsync_data[index]) - test.endSection() - -def verify_log_response_credentials(actual_cloudsync_data, expected_cloudsync_data): - """ - This function is used for verifying the expected and actual cloud-sync log data. - """ - test.startSection("Verification of cloud response for code %s" %actual_cloudsync_data[config.CODE_INDEX]) - expected_cloudsync_data = expected_cloudsync_data.split(',') - current_epoch_value = time.time() + if len(expected_cloudsync_data) == config.HD_OPMODES_MSG_PARAMETER_LEN : + for index in (config.CRC_INDEX, config.CODE_INDEX, config.PARAMETER_COUNT, config.OPMODE_INDEX, config.SUBMODE): + test.compare(expected_cloudsync_data[index], actual_cloudsync_data[index], "cloud sync data %s is verified" %expected_cloudsync_data[index]) - epoch_value_status = utility.get_epoch_value_consistancy(current_epoch_value, actual_cloudsync_data[config.EPOCH_INDEX]) - test.verify(epoch_value_status, "epoch value should be in range and it is verified") + if len(expected_cloudsync_data) == config.HD_OPMODES_CREDENTIAL_PARAMETER_LEN: + for index in (config.CRC_INDEX, config.CODE_INDEX, config.PARAMETER_COUNT, config.OPMODE_INDEX): + test.compare(expected_cloudsync_data[index], actual_cloudsync_data[index], "cloud sync data %s is verified" %expected_cloudsync_data[index]) - for index in (config.CRC_INDEX, config.CODE_INDEX, config.PARAMETER_COUNT, config.OPMODE_INDEX): - 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(3) + utils.waitForGUI(2) verify_hd_opmodes() utils.tstDone()