# -*- 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-treatment_screen # date 2022/04/09 # author Amritha debnath # joseph varghese # # # NOTE: # This test verifies the cloud sync - treatment screen. import csv import os from dialin.ui.hd_simulator import HDSimulator from dialin.ui import utils from configuration import utility from configuration import config from dialin.utils.conversions import float_to_bytearray, integer_to_bytearray,unsigned_integer_to_bytearray hd_simulator = HDSimulator() CLOUD_SYNC_LOG_LOCATION = '/home/denali/Desktop/sd-card/cloudsync/' MESSAGE_1 = '1639391827,1,0,2008,1,Tx_code' def get_cloud_sync_input_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}_inp.log' @return latest_file - (string) returns latest file that append on log folder from sd-data """ try: current_date = utility.get_current_date_and_time(date_format = "%Y_%m_%d") latest_file = CLOUD_SYNC_LOG_LOCATION+current_date+'_inp.buf' return latest_file except: return False def verify_ui_response(): """ This function is used for verify the treatment log changes """ 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, num_of_instructions, 1): if indicator != num_of_instructions: mouseClick(waitForObject(names.o_patient_Disconnection_right_arrow)) snooze(2) def get_cloud_sync_output_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: current_date = utility.get_current_date_and_time(date_format = "%Y_%m_%d") latest_file = CLOUD_SYNC_LOG_LOCATION+current_date+'_out.buf' return latest_file except: return False def retrive_log_data(): """ 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 """ 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],reader[7]) 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 set_data_in_cloud_sync_output_file(location, 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 """ with open(location, "a") as filereader: filereader.write(message) utils.waitForGUI(5) def main(): utility.append_cloudsync_credentials_file() utils.tstStart(__file__) startApplication(config.AUT_NAME) utils.waitForGUI(1.5) cloud_out_log = get_cloud_sync_output_file() set_data_in_cloud_sync_output_file(cloud_out_log, MESSAGE_1) verify_ui_response() verify_log_response() utils.tstDone()