# -*- 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 os import csv from builtins import int as pyInt from builtins import str as pyStr 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 from dialin.utils.conversions import float_to_bytearray, integer_to_bytearray,unsigned_integer_to_bytearray hd_simulator = HDSimulator() expected_crc = 0 expected_code = 1006 expected_parameter = [] expected_opmodes = [0, 1, 2, 3, 4, 5, 6, 7] expected_submode = 0 PEM_FILES = ['1.pem', '2.pem', '3.pem' ] 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' expected_crc = '0' expected_code = '1006' expected_parameter = '2' expected_opmodes = [0, 1, 2, 3, 4, 5, 6, 7] expected_submode = '0' PEM_FILES = ['1.pem', '2.pem', '3.pem' ] 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) # 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("Initial 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("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) # utils.waitForGUI(1) # hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.NUM_OF_MODES.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) # test.endSection() def retrive_log_data(): file_name = utility.get_extracted_file_inp_buf() try: with open(file_name,mode = 'r') as f: contents = csv.reader(f) try: for reader in reversed(list(contents)): test.log(str(reader)) return (reader[0],reader[1],reader[2],reader[3],reader[4],reader[5],reader[6]) except: test.fail("application log data is corrupted") except: test.fail("Log file is not created or log file is not created based on standard log naming format.") def verify_cloud_sync_log_data(crc,code,parameter,opmode,submode): """ """ test.startSection("verifying cloud sync log data ") test.compare(crc,expected_crc) test.compare(code,expected_code) test.compare(parameter,expected_parameter) # for opmode in range (len(expected_opmodes)): # test.compare(opmode,expected_opmodes[0]) test.compare(opmode,expected_opmodes) test.compare(submode,expected_submode) test.endSection() def main(): utility.append_cloudsync_credentials_file() utils.tstStart(__file__) startApplication(config.AUT_NAME) utils.waitForGUI(1.5) navigate_to_hd_opmodes() epoch_time,serial_num,crc,code,parameter,opmode,submode = retrive_log_data() verify_cloud_sync_log_data(crc,code,parameter,opmode,submode) utils.tstDone()