def test1(): """ Method to run Test Case 1 """ Logger.info("Ejecutando Caso de Prueba 1") test_route = os.path.abspath(os.path.join(os.path.dirname(__file__), 'test', 'smoketest', 'build_3', 'test_case_b3_1.py')) try: result_code = pytest.main(["-s", test_route]) TestResults.log_test_results(result_code) except RuntimeError: Logger.error("Test Fallido" + str(sys.exc_info()[0])) return jsonify(Logger.logger_content())
def test_case_2(self): """ Verifies Facebook, Instagram and Youtube are succesfully opened in the phone Pre-requisites: Facebook, Instagram and Youtube must be installed """ package_names = [FACEBOOK_PACKAGE, INSTAGRAM_PACKAGE, YOUTUBE_PACKAGE] for app in package_names: assert self.test_functions.test_open_app(app) Logger.success("Se abrió la aplicación " + app) self.test_functions.test_timer(2000)
def test_case_1(self): """ Verifies that a phone call is succesuflly started and finished Pre-requisites: The phone number must consist of 10 numeric digits and corresponds to a existing phone number """ assert self.test_functions.test_make_phone_call(self.phone_number) Logger.success("Se inicio una llamada") self.test_functions.test_timer(9000) assert self.test_functions.test_end_call() Logger.success("Se terminó una llamada") self.test_functions.test_timer(9000)
def test_case_5(self): """ Verifies that five consecutive phone calls are successfully started and finished Pre-requisites: The phone number must consist of 10 numeric digits and corresponds to a existing phone number """ for i in range(1, 6): assert self.test_functions.test_make_phone_call(self.phone_number) Logger.success("Se inicio la llamada " + i) self.test_functions.test_timer(5000) assert self.test_functions.test_end_call() Logger.success("Se terminó la llamada " + i) self.test_functions.test_timer(5000)
def test_logger(): """ Verifies that the logger class saves properly the log messages in a file. Pre-requisites: None """ Logger.debug("test debug") Logger.info("test info") Logger.success("test success") Logger.warning("test warning") Logger.info("test info") file_name = Logger.log_file.file_obj.name Logger.log_file = None log_file = FileManager(file_name, "r") content = log_file.read() assert not content
def test_case_4(self): """ Verifies that a phone call is successully started and finished. Then, verifies that the phone number that received the call is the the logcat of the phone that made the call Pre-requisites: The phone number must consist of 10 numeric digits and corresponds to a existing phone number """ self.test_case_b4_1.test_case_1() log_name = "{}.{}".format( str(datetime.datetime.now().strftime("%Y-%m-%d %H-%M-%S")), "log") assert self.test_functions.test_download_logcat(log_name) Logger.success("Se descargó el logcat") assert self.test_functions.test_validate_phone_number( log_name, self.phone_number) Logger.success("Se validó el teléfono en el logcat")
def log_test_results(code): """ Sends a message to the Logger Class """ if code == 0: Logger.success("Prueba Exitosa") elif code == 1: Logger.warning("Prueba Fallida") elif code == 2: Logger.warning("Ejecución interrumpida por el usuario") else: Logger.error("Error interno al ejecutar la prueba")
def test_case_3(self): """ Verifies that an apk is successfully downloaded from an URL in the PC and installed in a phone. Then verifies that a call is successfully made Pre-requisites: The URL must correspond to an apk location """ apk_path = self.test_functions.test_download_apk(self.apk_url) self.test_functions.test_timer(3000) Logger.success("Se descargó un apk") assert self.test_functions.test_install_apk(apk_path) self.test_functions.test_timer(3000) Logger.success("Se instaló un apk") Logger.info("Ejecutando Caso de Prueba 1") test_route = os.path.abspath( os.path.join(os.path.dirname(__file__), 'test_case_b3_1.py')) pytest.main(["-s", test_route])