chores: add typing to ui-test

This commit is contained in:
Anthony Laibe 2022-06-24 09:47:24 +02:00 committed by Anthony Laibe
parent 9d2862a602
commit 49b592daa3
7 changed files with 26 additions and 23 deletions

View File

@ -4,13 +4,13 @@ from drivers.SquishDriverVerification import *
def click_on_an_object(obj): def click_on_an_object(objName: str):
click_obj_by_name(obj) click_obj_by_name(objName)
def input_text(text, obj): def input_text(text: str, objName: str):
type(obj, text) type(objName, text)
def object_not_enabled(obj): def object_not_enabled(objName: str):
verify_object_enabled(obj, 500, False) verify_object_enabled(objName, 500, False)

View File

@ -9,16 +9,19 @@
# *****************************************************************************/ # *****************************************************************************/
#It defines a basic status account object. #It defines a basic status account object.
from typing import Optional
class StatusAccount(): class StatusAccount():
__name = None __name = ""
__password = None __password = None
def __init__(self, name, password = None): def __init__(self, name: str, password: Optional[str] = None):
self.__name = name self.__name = name
self.__password = password self.__password = password
def get_name(self): def get_name(self) -> str:
return self.__name return self.__name
def get_password(self): def get_password(self) -> Optional[str]:
return self.__password return self.__password

View File

@ -1,9 +1,9 @@
from drivers.SquishDriver import * from drivers.SquishDriver import *
def press_enter(objName): def press_enter(objName: str):
type(objName, "<Return>") type(objName, "<Return>")
def press_backspace(objName): def press_backspace(objName: str):
type(objName, "<Backspace>") type(objName, "<Backspace>")

View File

@ -25,7 +25,7 @@ _MIN_WAIT_OBJ_TIMEOUT = 500
# Waits for the given object is loaded, visible and enabled. # Waits for the given object is loaded, visible and enabled.
# It returns a tuple: True in case it is found. Otherwise, false. And the object itself. # It returns a tuple: True in case it is found. Otherwise, false. And the object itself.
def is_loaded_visible_and_enabled(objName, timeout=_MAX_WAIT_OBJ_TIMEOUT): def is_loaded_visible_and_enabled(objName: str, timeout: int=_MAX_WAIT_OBJ_TIMEOUT):
obj = None obj = None
try: try:
obj = squish.waitForObject(getattr(names, objName), timeout) obj = squish.waitForObject(getattr(names, objName), timeout)
@ -36,7 +36,7 @@ def is_loaded_visible_and_enabled(objName, timeout=_MAX_WAIT_OBJ_TIMEOUT):
# Waits for the given object is loaded and might be not visible and/or not enabled: # Waits for the given object is loaded and might be not visible and/or not enabled:
# It returns a tuple: True in case it is found. Otherwise, false. And the object itself. # It returns a tuple: True in case it is found. Otherwise, false. And the object itself.
def is_loaded(objName): def is_loaded(objName: str):
obj = None obj = None
try: try:
obj = squish.findObject(getattr(names, objName)) obj = squish.findObject(getattr(names, objName))
@ -68,7 +68,7 @@ def click_obj(obj):
# It executes the click action into object with given object name: # It executes the click action into object with given object name:
def click_obj_by_name(objName): def click_obj_by_name(objName: str):
try: try:
obj = squish.waitForObject(getattr(names, objName)) obj = squish.waitForObject(getattr(names, objName))
squish.mouseClick(obj, squish.Qt.LeftButton) squish.mouseClick(obj, squish.Qt.LeftButton)
@ -77,7 +77,7 @@ def click_obj_by_name(objName):
return False return False
def check_obj_by_name(objName): def check_obj_by_name(objName: str):
try: try:
obj = squish.waitForObject(getattr(names, objName)) obj = squish.waitForObject(getattr(names, objName))
obj.checked = True obj.checked = True
@ -86,7 +86,7 @@ def check_obj_by_name(objName):
return False return False
def is_text_matching(objName, text): def is_text_matching(objName: str, text: str):
try: try:
obj = squish.waitForObject(getattr(names, objName)) obj = squish.waitForObject(getattr(names, objName))
test.compare(obj.text, text, "Found the following text " + text) test.compare(obj.text, text, "Found the following text " + text)
@ -96,7 +96,7 @@ def is_text_matching(objName, text):
# It types the specified text into the given object (as if the user had used the keyboard): # It types the specified text into the given object (as if the user had used the keyboard):
def type(objName, text): def type(objName: str, text: str):
try: try:
obj = squish.findObject(getattr(names, objName)) obj = squish.findObject(getattr(names, objName))
squish.type(obj, text) squish.type(obj, text)

View File

@ -7,10 +7,10 @@ _MAX_WAIT_OBJ_TIMEOUT = 5000
_MIN_WAIT_OBJ_TIMEOUT = 500 _MIN_WAIT_OBJ_TIMEOUT = 500
def verify_screen(objName, timeout=_MAX_WAIT_OBJ_TIMEOUT): def verify_screen(objName: str, timeout: int=_MAX_WAIT_OBJ_TIMEOUT):
result = is_loaded_visible_and_enabled(objName, timeout) result = is_loaded_visible_and_enabled(objName, timeout)
test.verify(result, True) test.verify(result, True)
def verify_object_enabled(objName, timeout=_MIN_WAIT_OBJ_TIMEOUT, condition=True): def verify_object_enabled(objName: str, timeout: int=_MIN_WAIT_OBJ_TIMEOUT, condition: bool=True):
result = is_loaded_visible_and_enabled(objName, timeout) result = is_loaded_visible_and_enabled(objName, timeout)
test.verify(result, condition) test.verify(result, condition)

View File

@ -11,7 +11,7 @@
class StatusProcess: class StatusProcess:
__context = None __context = None
# Variable used to determine if it is needed to verify the process success or the process failure behavior # Variable used to determine if it is needed to verify the process success or the process failure behavior
__verify_success = True __verify_success: bool = True
def __init__(self, context): def __init__(self, context):
self.__context = context self.__context = context
@ -26,7 +26,7 @@ class StatusProcess:
# It is used to execute the specific status process steps. # It is used to execute the specific status process steps.
#@abstractmethod #@abstractmethod
def execute_process(self, verify_success = True): def execute_process(self, verify_success: bool = True):
self.__verify_success = verify_success self.__verify_success = verify_success
print("TODO: Invoke navigations") print("TODO: Invoke navigations")
# *** # ***

View File

@ -2,7 +2,7 @@ import os, shutil
import os.path as path import os.path as path
def erase_directory(dir): def erase_directory(dir: str):
directory = path.abspath(path.join(__file__ , dir)) directory = path.abspath(path.join(__file__ , dir))
if (os.path.isdir(directory)): if (os.path.isdir(directory)):
print(directory) print(directory)