2017-08-28 10:02:20 +00:00
|
|
|
import asyncio
|
2023-06-23 15:08:28 +00:00
|
|
|
import functools
|
|
|
|
import json
|
2018-01-26 11:07:09 +00:00
|
|
|
import logging
|
2020-11-11 15:37:27 +00:00
|
|
|
import os
|
2023-06-23 15:08:28 +00:00
|
|
|
import time
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
from urllib3.exceptions import MaxRetryError
|
|
|
|
|
2018-11-07 12:26:32 +00:00
|
|
|
from support.appium_container import AppiumContainer
|
2018-04-28 09:02:39 +00:00
|
|
|
from support.test_data import TestSuiteData
|
2022-04-01 04:44:31 +00:00
|
|
|
|
|
|
|
|
2023-09-06 03:07:12 +00:00
|
|
|
async def start_threads(test_name: str, quantity: int, func: type, returns: dict, **kwargs):
|
2017-08-28 10:02:20 +00:00
|
|
|
loop = asyncio.get_event_loop()
|
2023-06-23 15:08:28 +00:00
|
|
|
# from tests.conftest import sauce
|
|
|
|
# for _ in range(60):
|
|
|
|
# if 16 - len([job for job in sauce.jobs.get_user_jobs() if job['status'] == 'in progress']) < quantity:
|
|
|
|
# time.sleep(10)
|
2018-01-26 11:07:09 +00:00
|
|
|
for i in range(quantity):
|
2023-09-06 03:07:12 +00:00
|
|
|
returns[i] = loop.run_in_executor(None, functools.partial(func, **kwargs))
|
2018-01-26 11:07:09 +00:00
|
|
|
for k in returns:
|
2023-06-23 15:08:28 +00:00
|
|
|
for _ in range(3):
|
|
|
|
try:
|
|
|
|
returns[k] = await returns[k]
|
|
|
|
break
|
|
|
|
except MaxRetryError:
|
2023-07-04 17:26:05 +00:00
|
|
|
print("MaxRetryError when creating a driver for %s" % test_name)
|
2023-06-23 15:08:28 +00:00
|
|
|
time.sleep(10)
|
2024-03-12 20:27:38 +00:00
|
|
|
# for k in returns:
|
|
|
|
# for _ in range(30):
|
|
|
|
# try:
|
|
|
|
# k.session_id
|
|
|
|
# break
|
|
|
|
# except AttributeError:
|
|
|
|
# print("AttributeError when creating a driver for %s" % test_name)
|
|
|
|
# time.sleep(3)
|
2018-01-26 11:07:09 +00:00
|
|
|
return returns
|
|
|
|
|
|
|
|
|
2022-11-29 05:19:01 +00:00
|
|
|
async def run_in_parallel(funcs):
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
res = []
|
|
|
|
returns = []
|
|
|
|
for func in funcs:
|
|
|
|
try:
|
2023-03-26 18:56:29 +00:00
|
|
|
res.append(loop.run_in_executor(None, functools.partial(func[0], **func[1])))
|
2022-11-29 05:19:01 +00:00
|
|
|
except IndexError:
|
|
|
|
res.append(loop.run_in_executor(None, func[0]))
|
|
|
|
for k in res:
|
|
|
|
returns.append(await k)
|
|
|
|
return returns
|
|
|
|
|
|
|
|
|
2018-01-26 11:07:09 +00:00
|
|
|
def get_current_time():
|
|
|
|
return datetime.now().strftime('%-m%-d%-H%-M%-S')
|
|
|
|
|
|
|
|
|
2018-04-28 09:02:39 +00:00
|
|
|
def debug(text: str):
|
2018-08-13 12:09:53 +00:00
|
|
|
logging.debug(text)
|
2017-08-28 10:02:20 +00:00
|
|
|
|
2023-06-23 15:08:28 +00:00
|
|
|
|
2021-04-30 09:31:39 +00:00
|
|
|
appium_root_project_path = os.path.join(os.sep.join(__file__.split(os.sep)[:-1]), '../')
|
|
|
|
|
2019-11-29 11:48:07 +00:00
|
|
|
pytest_config_global = dict()
|
2018-02-26 23:38:56 +00:00
|
|
|
test_suite_data = TestSuiteData()
|
2018-11-07 12:26:32 +00:00
|
|
|
appium_container = AppiumContainer()
|
2017-09-26 10:50:34 +00:00
|
|
|
|
2023-03-30 13:14:27 +00:00
|
|
|
common_password = 'qwerty1234'
|
2018-08-23 13:50:19 +00:00
|
|
|
unique_password = 'unique' + get_current_time()
|
2020-05-14 10:41:09 +00:00
|
|
|
pin = '121212'
|
|
|
|
puk = '000000000000'
|
2023-06-23 15:08:28 +00:00
|
|
|
pair_code = '000000'
|
2021-08-09 11:16:02 +00:00
|
|
|
background_service_message = 'Background service for notifications'
|
2018-07-19 09:57:45 +00:00
|
|
|
|
2020-10-14 09:34:53 +00:00
|
|
|
test_dapp_web_url = "status-im.github.io/dapp"
|
2022-07-29 07:46:04 +00:00
|
|
|
test_dapp_url = 'https://simpledapp.status.im/'
|
|
|
|
test_dapp_name = 'simpledapp.status.im'
|
2020-08-14 16:05:41 +00:00
|
|
|
|
2023-01-09 13:46:24 +00:00
|
|
|
emojis = {'thumbs-up': 2, 'thumbs-down': 3, 'love': 1, 'laugh': 4, 'angry': 6, 'sad': 5}
|
2020-11-11 15:37:27 +00:00
|
|
|
|
|
|
|
with open(os.sep.join(__file__.split(os.sep)[:-1]) + '/../../../translations/en.json') as json_file:
|
|
|
|
transl = json.load(json_file)
|