2017-08-28 13:02:20 +03:00
|
|
|
import asyncio
|
2023-06-23 18:08:28 +03:00
|
|
|
import functools
|
|
|
|
import json
|
2020-11-11 16:37:27 +01:00
|
|
|
import os
|
2023-06-23 18:08:28 +03:00
|
|
|
import time
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
from urllib3.exceptions import MaxRetryError
|
|
|
|
|
2018-04-28 11:02:39 +02:00
|
|
|
from support.test_data import TestSuiteData
|
2022-04-01 07:44:31 +03:00
|
|
|
|
|
|
|
|
2023-09-06 06:07:12 +03:00
|
|
|
async def start_threads(test_name: str, quantity: int, func: type, returns: dict, **kwargs):
|
2017-08-28 13:02:20 +03:00
|
|
|
loop = asyncio.get_event_loop()
|
2018-01-26 13:07:09 +02:00
|
|
|
for i in range(quantity):
|
2023-09-06 06:07:12 +03:00
|
|
|
returns[i] = loop.run_in_executor(None, functools.partial(func, **kwargs))
|
2018-01-26 13:07:09 +02:00
|
|
|
for k in returns:
|
2023-06-23 18:08:28 +03:00
|
|
|
for _ in range(3):
|
|
|
|
try:
|
|
|
|
returns[k] = await returns[k]
|
|
|
|
break
|
|
|
|
except MaxRetryError:
|
2023-07-04 20:26:05 +03:00
|
|
|
print("MaxRetryError when creating a driver for %s" % test_name)
|
2023-06-23 18:08:28 +03:00
|
|
|
time.sleep(10)
|
2018-01-26 13:07:09 +02:00
|
|
|
return returns
|
|
|
|
|
|
|
|
|
2022-11-29 07:19:01 +02:00
|
|
|
async def run_in_parallel(funcs):
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
res = []
|
|
|
|
returns = []
|
|
|
|
for func in funcs:
|
|
|
|
try:
|
2023-03-26 20:56:29 +02:00
|
|
|
res.append(loop.run_in_executor(None, functools.partial(func[0], **func[1])))
|
2022-11-29 07:19:01 +02: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 13:07:09 +02:00
|
|
|
def get_current_time():
|
|
|
|
return datetime.now().strftime('%-m%-d%-H%-M%-S')
|
|
|
|
|
|
|
|
|
2019-11-29 13:48:07 +02:00
|
|
|
pytest_config_global = dict()
|
2018-02-27 00:38:56 +01:00
|
|
|
test_suite_data = TestSuiteData()
|
2017-09-26 13:50:34 +03:00
|
|
|
|
2023-03-30 15:14:27 +02:00
|
|
|
common_password = 'qwerty1234'
|
2020-08-14 18:05:41 +02:00
|
|
|
|
2023-01-09 14:46:24 +01:00
|
|
|
emojis = {'thumbs-up': 2, 'thumbs-down': 3, 'love': 1, 'laugh': 4, 'angry': 6, 'sad': 5}
|
2020-11-11 16:37:27 +01:00
|
|
|
|
|
|
|
with open(os.sep.join(__file__.split(os.sep)[:-1]) + '/../../../translations/en.json') as json_file:
|
|
|
|
transl = json.load(json_file)
|