2023-08-04 18:27:03 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
import allure
|
|
|
|
import squish
|
|
|
|
|
|
|
|
import configs
|
2024-10-04 07:54:43 +00:00
|
|
|
import driver
|
2023-10-23 11:53:11 +00:00
|
|
|
from driver.server import SquishServer
|
2023-08-04 18:27:03 +00:00
|
|
|
|
2023-11-30 13:07:26 +00:00
|
|
|
LOG = logging.getLogger(__name__)
|
2023-08-04 18:27:03 +00:00
|
|
|
|
|
|
|
|
2024-02-09 14:30:35 +00:00
|
|
|
@allure.step('Get application context of "{0}"')
|
|
|
|
def get_context(aut_id: str):
|
2024-02-29 07:40:37 +00:00
|
|
|
LOG.info('Attaching to: %s', aut_id)
|
|
|
|
try:
|
2024-10-04 07:54:43 +00:00
|
|
|
context = driver.attachToApplication(aut_id, SquishServer().host, SquishServer().port)
|
2024-02-29 07:40:37 +00:00
|
|
|
if context is not None:
|
|
|
|
LOG.info('AUT %s context found', aut_id)
|
|
|
|
return context
|
|
|
|
except RuntimeError as error:
|
|
|
|
LOG.error('AUT %s context has not been found', aut_id)
|
|
|
|
raise error
|
2023-08-04 18:27:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
@allure.step('Detaching')
|
|
|
|
def detach():
|
2024-10-04 07:54:43 +00:00
|
|
|
for ctx in driver.applicationContextList():
|
2023-08-04 18:27:03 +00:00
|
|
|
ctx.detach()
|
|
|
|
assert squish.waitFor(lambda: not ctx.isRunning, configs.timeouts.APP_LOAD_TIMEOUT_MSEC)
|
2023-11-30 13:07:26 +00:00
|
|
|
LOG.info('All AUTs detached')
|