mirror of
https://github.com/chatmail/core.git
synced 2026-05-20 07:16:31 +03:00
python: create test accounts in parallel
This commit is contained in:
@@ -2,6 +2,7 @@ import json
|
|||||||
import os
|
import os
|
||||||
from typing import AsyncGenerator, List, Optional
|
from typing import AsyncGenerator, List, Optional
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import pytest_asyncio
|
import pytest_asyncio
|
||||||
|
|
||||||
@@ -51,11 +52,13 @@ class ACFactory:
|
|||||||
await bot.configure(credentials["email"], credentials["password"])
|
await bot.configure(credentials["email"], credentials["password"])
|
||||||
return bot
|
return bot
|
||||||
|
|
||||||
|
async def get_online_account(self) -> Account:
|
||||||
|
account = await self.new_configured_account()
|
||||||
|
await account.start_io()
|
||||||
|
return account
|
||||||
|
|
||||||
async def get_online_accounts(self, num: int) -> List[Account]:
|
async def get_online_accounts(self, num: int) -> List[Account]:
|
||||||
accounts = [await self.new_configured_account() for _ in range(num)]
|
return await asyncio.gather(*[self.get_online_account() for _ in range(num)])
|
||||||
for account in accounts:
|
|
||||||
await account.start_io()
|
|
||||||
return accounts
|
|
||||||
|
|
||||||
async def send_message(
|
async def send_message(
|
||||||
self,
|
self,
|
||||||
|
|||||||
Reference in New Issue
Block a user