mirror of
https://github.com/chatmail/core.git
synced 2026-05-16 21:36:30 +03:00
api(deltachat-rpc-client): add Account.add_transport()
This commit is contained in:
@@ -110,6 +110,11 @@ class Account:
|
|||||||
"""Configure an account."""
|
"""Configure an account."""
|
||||||
yield self._rpc.configure.future(self.id)
|
yield self._rpc.configure.future(self.id)
|
||||||
|
|
||||||
|
@futuremethod
|
||||||
|
def add_transport(self, params):
|
||||||
|
"""Add a new transport."""
|
||||||
|
yield self._rpc.add_transport.future(self.id, params)
|
||||||
|
|
||||||
def bring_online(self):
|
def bring_online(self):
|
||||||
"""Start I/O and wait until IMAP becomes IDLE."""
|
"""Start I/O and wait until IMAP becomes IDLE."""
|
||||||
self.start_io()
|
self.start_io()
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class ACFactory:
|
|||||||
addr, password = self.get_credentials()
|
addr, password = self.get_credentials()
|
||||||
account = self.get_unconfigured_account()
|
account = self.get_unconfigured_account()
|
||||||
params = {"addr": addr, "password": password}
|
params = {"addr": addr, "password": password}
|
||||||
yield account._rpc.add_transport.future(account.id, params)
|
yield account.add_transport.future(params)
|
||||||
|
|
||||||
assert account.is_configured()
|
assert account.is_configured()
|
||||||
return account
|
return account
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ def test_event_on_configuration(acfactory: ACFactory) -> None:
|
|||||||
account = acfactory.get_unconfigured_account()
|
account = acfactory.get_unconfigured_account()
|
||||||
account.clear_all_events()
|
account.clear_all_events()
|
||||||
assert not account.is_configured()
|
assert not account.is_configured()
|
||||||
future = account._rpc.add_transport.future(account.id, {"addr": addr, "password": password})
|
future = account.add_transport.future({"addr": addr, "password": password})
|
||||||
while True:
|
while True:
|
||||||
event = account.wait_for_event()
|
event = account.wait_for_event()
|
||||||
if event.kind == EventType.ACCOUNTS_ITEM_CHANGED:
|
if event.kind == EventType.ACCOUNTS_ITEM_CHANGED:
|
||||||
|
|||||||
@@ -63,8 +63,7 @@ def test_acfactory(acfactory) -> None:
|
|||||||
def test_configure_starttls(acfactory) -> None:
|
def test_configure_starttls(acfactory) -> None:
|
||||||
addr, password = acfactory.get_credentials()
|
addr, password = acfactory.get_credentials()
|
||||||
account = acfactory.get_unconfigured_account()
|
account = acfactory.get_unconfigured_account()
|
||||||
account._rpc.add_transport(
|
account.add_transport(
|
||||||
account.id,
|
|
||||||
{
|
{
|
||||||
"addr": addr,
|
"addr": addr,
|
||||||
"password": password,
|
"password": password,
|
||||||
@@ -81,8 +80,7 @@ def test_configure_ip(acfactory) -> None:
|
|||||||
ip_address = socket.gethostbyname(addr.rsplit("@")[-1])
|
ip_address = socket.gethostbyname(addr.rsplit("@")[-1])
|
||||||
|
|
||||||
with pytest.raises(JsonRpcError):
|
with pytest.raises(JsonRpcError):
|
||||||
account._rpc.add_transport(
|
account.add_transport(
|
||||||
account.id,
|
|
||||||
{
|
{
|
||||||
"addr": addr,
|
"addr": addr,
|
||||||
"password": password,
|
"password": password,
|
||||||
@@ -96,8 +94,7 @@ def test_configure_alternative_port(acfactory) -> None:
|
|||||||
"""Test that configuration with alternative port 443 works."""
|
"""Test that configuration with alternative port 443 works."""
|
||||||
addr, password = acfactory.get_credentials()
|
addr, password = acfactory.get_credentials()
|
||||||
account = acfactory.get_unconfigured_account()
|
account = acfactory.get_unconfigured_account()
|
||||||
account._rpc.add_transport(
|
account.add_transport(
|
||||||
account.id,
|
|
||||||
{
|
{
|
||||||
"addr": addr,
|
"addr": addr,
|
||||||
"password": password,
|
"password": password,
|
||||||
@@ -111,8 +108,7 @@ def test_configure_alternative_port(acfactory) -> None:
|
|||||||
def test_list_transports(acfactory) -> None:
|
def test_list_transports(acfactory) -> None:
|
||||||
addr, password = acfactory.get_credentials()
|
addr, password = acfactory.get_credentials()
|
||||||
account = acfactory.get_unconfigured_account()
|
account = acfactory.get_unconfigured_account()
|
||||||
account._rpc.add_transport(
|
account.add_transport(
|
||||||
account.id,
|
|
||||||
{
|
{
|
||||||
"addr": addr,
|
"addr": addr,
|
||||||
"password": password,
|
"password": password,
|
||||||
@@ -424,7 +420,7 @@ def test_wait_next_messages(acfactory) -> None:
|
|||||||
addr, password = acfactory.get_credentials()
|
addr, password = acfactory.get_credentials()
|
||||||
bot = acfactory.get_unconfigured_account()
|
bot = acfactory.get_unconfigured_account()
|
||||||
bot.set_config("bot", "1")
|
bot.set_config("bot", "1")
|
||||||
bot._rpc.add_transport(bot.id, {"addr": addr, "password": password})
|
bot.add_transport({"addr": addr, "password": password})
|
||||||
assert bot.is_configured()
|
assert bot.is_configured()
|
||||||
|
|
||||||
# There are no old messages and the call returns immediately.
|
# There are no old messages and the call returns immediately.
|
||||||
@@ -607,7 +603,7 @@ def test_reactions_for_a_reordering_move(acfactory, direct_imap):
|
|||||||
|
|
||||||
addr, password = acfactory.get_credentials()
|
addr, password = acfactory.get_credentials()
|
||||||
ac2 = acfactory.get_unconfigured_account()
|
ac2 = acfactory.get_unconfigured_account()
|
||||||
ac2._rpc.add_transport(ac2.id, {"addr": addr, "password": password})
|
ac2.add_transport({"addr": addr, "password": password})
|
||||||
ac2.set_config("mvbox_move", "1")
|
ac2.set_config("mvbox_move", "1")
|
||||||
assert ac2.is_configured()
|
assert ac2.is_configured()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user