mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
test: remove ThreadPoolExecutor from test_wait_next_messages
This commit is contained in:
@@ -399,9 +399,10 @@ class Account:
|
|||||||
next_msg_ids = self._rpc.get_next_msgs(self.id)
|
next_msg_ids = self._rpc.get_next_msgs(self.id)
|
||||||
return [Message(self, msg_id) for msg_id in next_msg_ids]
|
return [Message(self, msg_id) for msg_id in next_msg_ids]
|
||||||
|
|
||||||
|
@futuremethod
|
||||||
def wait_next_messages(self) -> list[Message]:
|
def wait_next_messages(self) -> list[Message]:
|
||||||
"""Wait for new messages and return a list of them."""
|
"""Wait for new messages and return a list of them."""
|
||||||
next_msg_ids = self._rpc.wait_next_msgs(self.id)
|
next_msg_ids = yield self._rpc.wait_next_msgs.future(self.id)
|
||||||
return [Message(self, msg_id) for msg_id in next_msg_ids]
|
return [Message(self, msg_id) for msg_id in next_msg_ids]
|
||||||
|
|
||||||
def wait_for_incoming_msg_event(self):
|
def wait_for_incoming_msg_event(self):
|
||||||
|
|||||||
@@ -484,15 +484,14 @@ def test_wait_next_messages(acfactory) -> None:
|
|||||||
# There are no old messages and the call returns immediately.
|
# There are no old messages and the call returns immediately.
|
||||||
assert not bot.wait_next_messages()
|
assert not bot.wait_next_messages()
|
||||||
|
|
||||||
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor:
|
|
||||||
# Bot starts waiting for messages.
|
# Bot starts waiting for messages.
|
||||||
next_messages_task = executor.submit(bot.wait_next_messages)
|
next_messages_task = bot.wait_next_messages.future()
|
||||||
|
|
||||||
alice_contact_bot = alice.create_contact(bot, "Bot")
|
alice_contact_bot = alice.create_contact(bot, "Bot")
|
||||||
alice_chat_bot = alice_contact_bot.create_chat()
|
alice_chat_bot = alice_contact_bot.create_chat()
|
||||||
alice_chat_bot.send_text("Hello!")
|
alice_chat_bot.send_text("Hello!")
|
||||||
|
|
||||||
next_messages = next_messages_task.result()
|
next_messages = next_messages_task()
|
||||||
|
|
||||||
if len(next_messages) == E2EE_INFO_MSGS:
|
if len(next_messages) == E2EE_INFO_MSGS:
|
||||||
next_messages += bot.wait_next_messages()
|
next_messages += bot.wait_next_messages()
|
||||||
|
|||||||
Reference in New Issue
Block a user