chore: replace conditions with function call in system.py
This commit is contained in:
parent
dc628f300a
commit
1c5aad7733
|
@ -3,6 +3,7 @@ import logging
|
|||
from os import path
|
||||
from scripts.utils.system_path import SystemPath
|
||||
from . import testpath, timeouts, testrail, squish, system
|
||||
from .system import get_platform
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -17,7 +18,7 @@ except ImportError:
|
|||
|
||||
if AUT_PATH is None:
|
||||
exit('Please add "AUT_PATH" in ./configs/_local.py')
|
||||
if system.IS_WIN and 'bin' not in AUT_PATH:
|
||||
if get_platform() == "Windows" and 'bin' not in AUT_PATH:
|
||||
exit('Please use launcher from "bin" folder in "AUT_PATH"')
|
||||
AUT_PATH = SystemPath(AUT_PATH)
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import os
|
||||
import platform
|
||||
|
||||
IS_LIN = True if platform.system() == 'Linux' else False
|
||||
IS_MAC = True if platform.system() == 'Darwin' else False
|
||||
IS_WIN = True if platform.system() == 'Windows' else False
|
||||
|
||||
OS_ID = 'lin' if IS_LIN else 'mac' if IS_MAC else 'win'
|
||||
def get_platform():
|
||||
return platform.system()
|
||||
|
||||
|
||||
DISPLAY = os.getenv('DISPLAY', ':0')
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import pytest
|
|||
from PIL import ImageGrab
|
||||
|
||||
import configs
|
||||
from configs.system import IS_LIN
|
||||
from configs.system import get_platform
|
||||
from fixtures.path import generate_test_info
|
||||
from scripts.utils.system_path import SystemPath
|
||||
|
||||
|
@ -62,7 +62,7 @@ def pytest_exception_interact(node):
|
|||
node_dir: SystemPath = configs.testpath.RUN / test_path / test_name / test_params
|
||||
node_dir.mkdir(parents=True, exist_ok=True)
|
||||
screenshot = node_dir / f'screenshot_{datetime.today().strftime("%Y-%m-%d %H-%M-%S")}.png'
|
||||
ImageGrab.grab(xdisplay=configs.system.DISPLAY if IS_LIN else None).save(screenshot)
|
||||
ImageGrab.grab(xdisplay=configs.system.DISPLAY if get_platform() == "Linux" else None).save(screenshot)
|
||||
allure.attach(
|
||||
name='Screenshot on fail',
|
||||
body=screenshot.read_bytes(),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import configs.system
|
||||
from configs import system
|
||||
|
||||
# Buttons
|
||||
BACKSPACE = 'Backspace'
|
||||
|
@ -9,5 +9,5 @@ RETURN = 'Return'
|
|||
SHIFT = 'Shift'
|
||||
|
||||
# Combinations
|
||||
SELECT_ALL = f'{CTRL if configs.system.IS_WIN else COMMAND}+A'
|
||||
SELECT_ALL = f'{CTRL if system.get_platform() == "Windows" else COMMAND}+A'
|
||||
OPEN_GOTO = f'{COMMAND}+{SHIFT}+G'
|
||||
|
|
|
@ -9,7 +9,7 @@ import configs
|
|||
import driver
|
||||
import shortuuid
|
||||
from datetime import datetime
|
||||
from configs.system import IS_LIN
|
||||
from configs.system import get_platform
|
||||
from driver import context
|
||||
from driver.server import SquishServer
|
||||
from gui.objects_map.names import statusDesktop_mainWindow
|
||||
|
@ -54,7 +54,7 @@ class AUT:
|
|||
rect = driver.object.globalBounds(driver.waitForObject(statusDesktop_mainWindow))
|
||||
img = ImageGrab.grab(
|
||||
bbox=(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height),
|
||||
xdisplay=configs.system.DISPLAY if IS_LIN else None)
|
||||
xdisplay=configs.system.DISPLAY if get_platform() == "Linux" else None)
|
||||
view = cv2.cvtColor(np.array(img), cv2.COLOR_BGR2RGB)
|
||||
cv2.imwrite(str(screenshot), view)
|
||||
|
||||
|
|
|
@ -183,11 +183,11 @@ class MainWindow(Window):
|
|||
create_password_view = profile_view.next()
|
||||
confirm_password_view = create_password_view.create_password(user_account.password)
|
||||
confirm_password_view.confirm_password(user_account.password)
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
BiometricsView().wait_until_appears().prefer_password()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
YourEmojihashAndIdenticonRingView().verify_emojihash_view_present().next()
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
AllowNotificationsView().start_using_status()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
if not configs.system.TEST_MODE:
|
||||
|
|
|
@ -419,7 +419,7 @@ class YourEmojihashAndIdenticonRingView(OnboardingView):
|
|||
def next(self):
|
||||
self._next_button.click()
|
||||
time.sleep(1)
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
return AllowNotificationsView().wait_until_appears()
|
||||
|
||||
@allure.step('Go back')
|
||||
|
|
|
@ -12,7 +12,7 @@ from PIL import ImageGrab
|
|||
import configs
|
||||
import constants
|
||||
import driver
|
||||
from configs.system import IS_LIN
|
||||
from configs.system import get_platform
|
||||
from scripts.tools.ocv import Ocv
|
||||
from scripts.utils.system_path import SystemPath
|
||||
|
||||
|
@ -57,7 +57,7 @@ class Image:
|
|||
rect = driver.object.globalBounds(driver.waitForObject(self.object_name))
|
||||
img = ImageGrab.grab(
|
||||
bbox=(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height),
|
||||
xdisplay=configs.system.DISPLAY if IS_LIN else None
|
||||
xdisplay=configs.system.DISPLAY if get_platform() == "Linux" else None
|
||||
)
|
||||
self._view = cv2.cvtColor(np.array(img), cv2.COLOR_BGR2RGB)
|
||||
|
||||
|
@ -212,7 +212,7 @@ def compare(actual: Image,
|
|||
):
|
||||
expected_fp = None
|
||||
if isinstance(expected, str):
|
||||
expected_fp = configs.testpath.TEST_VP / configs.system.OS_ID / expected
|
||||
expected_fp = configs.testpath.TEST_VP / configs.system.get_platform() / expected
|
||||
if not expected_fp.exists():
|
||||
expected_fp = configs.testpath.TEST_VP / expected
|
||||
expected = expected_fp
|
||||
|
|
|
@ -9,6 +9,7 @@ import allure
|
|||
import psutil
|
||||
|
||||
import configs
|
||||
from configs.system import get_platform
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -35,15 +36,13 @@ def find_free_port(start: int, step: int):
|
|||
def kill_process(pid):
|
||||
LOG.debug(f'Terminating process {pid}')
|
||||
|
||||
current_platform = platform.system()
|
||||
|
||||
try:
|
||||
if current_platform == "Windows":
|
||||
if get_platform() == "Windows":
|
||||
subprocess.call(f"taskkill /F /T /PID {str(pid)}")
|
||||
elif current_platform in ["Linux", "Darwin"]:
|
||||
elif get_platform() in ["Linux", "Darwin"]:
|
||||
os.kill(pid, signal.SIGKILL)
|
||||
else:
|
||||
raise NotImplementedError(f"Unsupported platform: {current_platform}")
|
||||
raise NotImplementedError(f"Unsupported platform: {get_platform()}")
|
||||
except Exception as e:
|
||||
print(f"Failed to terminate process {pid}: {e}")
|
||||
|
||||
|
|
|
@ -41,11 +41,11 @@ def test_mint_owner_token(keys_screen, main_window, user_account):
|
|||
create_password_view = profile_view.next()
|
||||
confirm_password_view = create_password_view.create_password(user_account.password)
|
||||
confirm_password_view.confirm_password(user_account.password)
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
BiometricsView().wait_until_appears().prefer_password()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
next_view = YourEmojihashAndIdenticonRingView().verify_emojihash_view_present().next()
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
next_view.start_using_status()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
if not configs.system.TEST_MODE:
|
||||
|
|
|
@ -86,7 +86,7 @@ def test_generate_new_keys_sign_out_from_settings(aut, main_window, keys_screen,
|
|||
|
||||
with step('Confirm password and login'):
|
||||
confirm_password_view.confirm_password(password)
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
assert BiometricsView().is_touch_id_button_visible(), f"TouchID button is not found"
|
||||
BiometricsView().wait_until_appears().prefer_password()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
|
@ -99,7 +99,7 @@ def test_generate_new_keys_sign_out_from_settings(aut, main_window, keys_screen,
|
|||
|
||||
with step('Click Start using Status'):
|
||||
next_view = emoji_hash_identicon_view.next()
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
next_view.start_using_status()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
if not configs.system.TEST_MODE:
|
||||
|
|
|
@ -45,11 +45,11 @@ def test_import_seed_phrase(keys_screen, main_window, aut: AUT, user_account, de
|
|||
create_password_view = profile_view.next()
|
||||
confirm_password_view = create_password_view.create_password(user_account.password)
|
||||
confirm_password_view.confirm_password(user_account.password)
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
BiometricsView().wait_until_appears().prefer_password()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
next_view = YourEmojihashAndIdenticonRingView().verify_emojihash_view_present().next()
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
next_view.start_using_status()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
if not configs.system.TEST_MODE:
|
||||
|
|
|
@ -45,11 +45,11 @@ def test_login_with_wrong_password(aut: AUT, keys_screen, main_window, error: st
|
|||
create_password_view = profile_view.next()
|
||||
confirm_password_view = create_password_view.create_password(user_one.password)
|
||||
confirm_password_view.confirm_password(user_one.password)
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
BiometricsView().wait_until_appears().prefer_password()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
next_view = YourEmojihashAndIdenticonRingView().verify_emojihash_view_present().next()
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
next_view.start_using_status()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
if not configs.system.TEST_MODE:
|
||||
|
|
|
@ -86,7 +86,7 @@ def test_sync_device_during_onboarding(multiple_instances):
|
|||
sync_result.sign_in()
|
||||
SplashScreen().wait_until_hidden()
|
||||
YourEmojihashAndIdenticonRingView().verify_emojihash_view_present().next()
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
AllowNotificationsView().start_using_status()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
if not configs.system.TEST_MODE:
|
||||
|
|
|
@ -46,11 +46,11 @@ def test_ens_name_purchase(keys_screen, main_window, user_account, ens_name):
|
|||
create_password_view = profile_view.next()
|
||||
confirm_password_view = create_password_view.create_password(user_account.password)
|
||||
confirm_password_view.confirm_password(user_account.password)
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
BiometricsView().wait_until_appears().prefer_password()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
next_view = YourEmojihashAndIdenticonRingView().verify_emojihash_view_present().next()
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
next_view.start_using_status()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
if not configs.system.TEST_MODE:
|
||||
|
|
|
@ -44,11 +44,11 @@ def test_wallet_send_0_eth(keys_screen, main_window, user_account, receiver_acco
|
|||
create_password_view = profile_view.next()
|
||||
confirm_password_view = create_password_view.create_password(user_account.password)
|
||||
confirm_password_view.confirm_password(user_account.password)
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
BiometricsView().wait_until_appears().prefer_password()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
next_view = YourEmojihashAndIdenticonRingView().verify_emojihash_view_present().next()
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
next_view.start_using_status()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
if not configs.system.TEST_MODE:
|
||||
|
|
|
@ -44,11 +44,11 @@ def test_wallet_send_nft(keys_screen, main_window, user_account, tab, receiver_a
|
|||
create_password_view = profile_view.next()
|
||||
confirm_password_view = create_password_view.create_password(user_account.password)
|
||||
confirm_password_view.confirm_password(user_account.password)
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
BiometricsView().wait_until_appears().prefer_password()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
next_view = YourEmojihashAndIdenticonRingView().verify_emojihash_view_present().next()
|
||||
if configs.system.IS_MAC:
|
||||
if configs.system.get_platform() == "Darwin":
|
||||
next_view.start_using_status()
|
||||
SplashScreen().wait_until_appears().wait_until_hidden()
|
||||
if not configs.system.TEST_MODE:
|
||||
|
|
Loading…
Reference in New Issue