chore: increased timeout for some buttons and created fixture to close apps before session
This commit is contained in:
parent
edc7a7566b
commit
60ee909598
|
@ -34,6 +34,7 @@ def setup_session_scope(
|
||||||
init_testrail_api,
|
init_testrail_api,
|
||||||
prepare_test_directory,
|
prepare_test_directory,
|
||||||
start_squish_server,
|
start_squish_server,
|
||||||
|
close_apps_before_start
|
||||||
):
|
):
|
||||||
LOG.info('Session startup...')
|
LOG.info('Session startup...')
|
||||||
yield
|
yield
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
import allure
|
import allure
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import logging
|
import logging
|
||||||
import configs
|
import configs
|
||||||
import constants
|
import constants
|
||||||
|
from configs import get_platform
|
||||||
from constants import UserAccount
|
from constants import UserAccount
|
||||||
from driver.aut import AUT
|
from driver.aut import AUT
|
||||||
from gui.main_window import MainWindow
|
from gui.main_window import MainWindow
|
||||||
from scripts.utils import system_path
|
from scripts.utils import system_path
|
||||||
|
from scripts.utils.local_system import get_pid_by_process_name, kill_process
|
||||||
from scripts.utils.system_path import SystemPath
|
from scripts.utils.system_path import SystemPath
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -87,3 +90,14 @@ def user_account(request) -> UserAccount:
|
||||||
def main_screen(user_account: UserAccount, main_window: MainWindow) -> MainWindow:
|
def main_screen(user_account: UserAccount, main_window: MainWindow) -> MainWindow:
|
||||||
main_window.authorize_user(user_account)
|
main_window.authorize_user(user_account)
|
||||||
return main_window
|
return main_window
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def close_apps_before_start():
|
||||||
|
if get_platform() == "Windows":
|
||||||
|
name = 'Status.exe'
|
||||||
|
else:
|
||||||
|
name = 'nim_status_client'
|
||||||
|
running_pids = get_pid_by_process_name(name)
|
||||||
|
if running_pids is not None:
|
||||||
|
for pid in running_pids:
|
||||||
|
kill_process(pid)
|
||||||
|
|
|
@ -48,7 +48,7 @@ class NewChannelPopup(ChannelPopup):
|
||||||
raise err
|
raise err
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
self._save_create_button.click()
|
self._save_create_button.click(timeout=5)
|
||||||
|
|
||||||
|
|
||||||
class EditChannelPopup(ChannelPopup):
|
class EditChannelPopup(ChannelPopup):
|
||||||
|
|
|
@ -25,7 +25,7 @@ class BlockUserPopup(BasePopup):
|
||||||
|
|
||||||
@allure.step('Block user')
|
@allure.step('Block user')
|
||||||
def block(self):
|
def block(self):
|
||||||
self._block_user_button.click()
|
self._block_user_button.click(timeout=5)
|
||||||
|
|
||||||
@allure.step('Get warning text')
|
@allure.step('Get warning text')
|
||||||
def get_warning_text(self) -> str:
|
def get_warning_text(self) -> str:
|
||||||
|
|
|
@ -3,7 +3,6 @@ import os
|
||||||
import signal
|
import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
import typing
|
import typing
|
||||||
import platform
|
|
||||||
|
|
||||||
import allure
|
import allure
|
||||||
import psutil
|
import psutil
|
||||||
|
@ -46,7 +45,6 @@ def kill_process(pid):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to terminate process {pid}: {e}")
|
print(f"Failed to terminate process {pid}: {e}")
|
||||||
|
|
||||||
|
|
||||||
@allure.step('System execute command')
|
@allure.step('System execute command')
|
||||||
def execute(
|
def execute(
|
||||||
command: list,
|
command: list,
|
||||||
|
@ -76,3 +74,14 @@ def run(
|
||||||
timeout=timeout_sec,
|
timeout=timeout_sec,
|
||||||
check=True
|
check=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@allure.step('Get pid by process name')
|
||||||
|
def get_pid_by_process_name(name):
|
||||||
|
pid_list = []
|
||||||
|
for proc in psutil.process_iter():
|
||||||
|
try:
|
||||||
|
if proc.name() == name and proc.status() != 'zombie':
|
||||||
|
pid_list.append(proc.pid)
|
||||||
|
except (psutil.NoSuchProcess, psutil.AccessDenied):
|
||||||
|
continue
|
||||||
|
return pid_list if len(pid_list) > 0 else None
|
||||||
|
|
Loading…
Reference in New Issue