From 0b73f9cebd1404f2f49db042a3560898dd4d18c5 Mon Sep 17 00:00:00 2001 From: link2xt Date: Mon, 8 Apr 2024 13:50:25 +0000 Subject: [PATCH] api(deltachat-rpc-client): add Account.bring_online() --- deltachat-rpc-client/src/deltachat_rpc_client/account.py | 8 ++++++++ .../src/deltachat_rpc_client/pytestplugin.py | 6 +----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/deltachat-rpc-client/src/deltachat_rpc_client/account.py b/deltachat-rpc-client/src/deltachat_rpc_client/account.py index e65246c98..d0f87ee2f 100644 --- a/deltachat-rpc-client/src/deltachat_rpc_client/account.py +++ b/deltachat-rpc-client/src/deltachat_rpc_client/account.py @@ -87,6 +87,14 @@ class Account: """Configure an account.""" yield self._rpc.configure.future(self.id) + def bring_online(self): + """Start I/O and wait until IMAP becomes IDLE.""" + self.start_io() + while True: + event = self.wait_for_event() + if event.kind == EventType.IMAP_INBOX_IDLE: + break + def create_contact(self, obj: Union[int, str, Contact], name: Optional[str] = None) -> Contact: """Create a new Contact or return an existing one. diff --git a/deltachat-rpc-client/src/deltachat_rpc_client/pytestplugin.py b/deltachat-rpc-client/src/deltachat_rpc_client/pytestplugin.py index e8c4885d8..cbc933654 100644 --- a/deltachat-rpc-client/src/deltachat_rpc_client/pytestplugin.py +++ b/deltachat-rpc-client/src/deltachat_rpc_client/pytestplugin.py @@ -54,11 +54,7 @@ class ACFactory: @futuremethod def get_online_account(self): account = yield self.new_configured_account.future() - account.start_io() - while True: - event = account.wait_for_event() - if event.kind == EventType.IMAP_INBOX_IDLE: - break + account.bring_online() return account def get_online_accounts(self, num: int) -> List[Account]: