mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
unify get_unconfigured_account and make_account
This commit is contained in:
@@ -244,7 +244,7 @@ class ACFactory:
|
|||||||
assert "addr" in configdict and "mail_pw" in configdict
|
assert "addr" in configdict and "mail_pw" in configdict
|
||||||
return configdict
|
return configdict
|
||||||
|
|
||||||
def make_account(self, quiet=False):
|
def get_unconfigured_account(self, quiet=False):
|
||||||
logid = "ac{}".format(len(self._accounts) + 1)
|
logid = "ac{}".format(len(self._accounts) + 1)
|
||||||
path = self.tmpdir.join(logid)
|
path = self.tmpdir.join(logid)
|
||||||
ac = Account(path.strpath, logging=self._logging)
|
ac = Account(path.strpath, logging=self._logging)
|
||||||
@@ -259,9 +259,6 @@ class ACFactory:
|
|||||||
def set_logging_default(self, logging):
|
def set_logging_default(self, logging):
|
||||||
self._logging = bool(logging)
|
self._logging = bool(logging)
|
||||||
|
|
||||||
def get_unconfigured_account(self):
|
|
||||||
return self.make_account()
|
|
||||||
|
|
||||||
def remove_preconfigured_keys(self):
|
def remove_preconfigured_keys(self):
|
||||||
self._preconfigured_keys = []
|
self._preconfigured_keys = []
|
||||||
|
|
||||||
@@ -297,7 +294,7 @@ class ACFactory:
|
|||||||
def get_online_configuring_account(self, sentbox=False, move=False,
|
def get_online_configuring_account(self, sentbox=False, move=False,
|
||||||
quiet=False, config={}):
|
quiet=False, config={}):
|
||||||
configdict = self.get_next_liveconfig()
|
configdict = self.get_next_liveconfig()
|
||||||
ac = self.make_account(quiet=quiet)
|
ac = self.get_unconfigured_account(quiet=quiet)
|
||||||
configdict.setdefault("displayname", os.path.basename(ac.db_path))
|
configdict.setdefault("displayname", os.path.basename(ac.db_path))
|
||||||
self._preconfigure_key(ac, configdict["addr"])
|
self._preconfigure_key(ac, configdict["addr"])
|
||||||
configdict.update(config)
|
configdict.update(config)
|
||||||
@@ -333,7 +330,7 @@ class ACFactory:
|
|||||||
direct_imap object of an online account. This simulates the user setting
|
direct_imap object of an online account. This simulates the user setting
|
||||||
up a new device without importing a backup.
|
up a new device without importing a backup.
|
||||||
"""
|
"""
|
||||||
ac = self.make_account()
|
ac = self.get_unconfigured_account()
|
||||||
# XXX we might want to transfer the key from the old account for some tests
|
# XXX we might want to transfer the key from the old account for some tests
|
||||||
self._preconfigure_key(ac, account.get_config("addr"))
|
self._preconfigure_key(ac, account.get_config("addr"))
|
||||||
ac.update_config(dict(
|
ac.update_config(dict(
|
||||||
@@ -371,7 +368,7 @@ class ACFactory:
|
|||||||
fn = module.__file__
|
fn = module.__file__
|
||||||
|
|
||||||
bot_cfg = self.get_next_liveconfig()
|
bot_cfg = self.get_next_liveconfig()
|
||||||
bot_ac = self.make_account()
|
bot_ac = self.get_unconfigured_account()
|
||||||
bot_ac.update_config(bot_cfg)
|
bot_ac.update_config(bot_cfg)
|
||||||
self._preconfigure_key(bot_ac, bot_cfg["addr"])
|
self._preconfigure_key(bot_ac, bot_cfg["addr"])
|
||||||
|
|
||||||
|
|||||||
@@ -2562,7 +2562,7 @@ class TestOnlineAccount:
|
|||||||
|
|
||||||
def test_configure_error_msgs_wrong_pw(self, acfactory):
|
def test_configure_error_msgs_wrong_pw(self, acfactory):
|
||||||
configdict = acfactory.get_next_liveconfig()
|
configdict = acfactory.get_next_liveconfig()
|
||||||
ac1 = acfactory.make_account()
|
ac1 = acfactory.get_unconfigured_account()
|
||||||
ac1.update_config(configdict)
|
ac1.update_config(configdict)
|
||||||
ac1.set_config("mail_pw", "abc") # Wrong mail pw
|
ac1.set_config("mail_pw", "abc") # Wrong mail pw
|
||||||
ac1.configure()
|
ac1.configure()
|
||||||
@@ -2574,7 +2574,7 @@ class TestOnlineAccount:
|
|||||||
assert "password" in ev.data2
|
assert "password" in ev.data2
|
||||||
|
|
||||||
def test_configure_error_msgs_invalid_server(self, acfactory):
|
def test_configure_error_msgs_invalid_server(self, acfactory):
|
||||||
ac2 = acfactory.make_account()
|
ac2 = acfactory.get_unconfigured_account()
|
||||||
ac2.set_config("addr", "abc@def.invalid") # mail server can't be reached
|
ac2.set_config("addr", "abc@def.invalid") # mail server can't be reached
|
||||||
ac2.set_config("mail_pw", "123")
|
ac2.set_config("mail_pw", "123")
|
||||||
ac2.configure()
|
ac2.configure()
|
||||||
@@ -2995,7 +2995,7 @@ class TestGroupStressTests:
|
|||||||
class TestOnlineConfigureFails:
|
class TestOnlineConfigureFails:
|
||||||
def test_invalid_password(self, acfactory):
|
def test_invalid_password(self, acfactory):
|
||||||
configdict = acfactory.get_next_liveconfig()
|
configdict = acfactory.get_next_liveconfig()
|
||||||
ac1 = acfactory.make_account()
|
ac1 = acfactory.get_unconfigured_account()
|
||||||
ac1.update_config(dict(addr=configdict["addr"], mail_pw="123"))
|
ac1.update_config(dict(addr=configdict["addr"], mail_pw="123"))
|
||||||
configtracker = ac1.configure()
|
configtracker = ac1.configure()
|
||||||
configtracker.wait_progress(500)
|
configtracker.wait_progress(500)
|
||||||
@@ -3003,7 +3003,7 @@ class TestOnlineConfigureFails:
|
|||||||
|
|
||||||
def test_invalid_user(self, acfactory):
|
def test_invalid_user(self, acfactory):
|
||||||
configdict = acfactory.get_next_liveconfig()
|
configdict = acfactory.get_next_liveconfig()
|
||||||
ac1 = acfactory.make_account()
|
ac1 = acfactory.get_unconfigured_account()
|
||||||
configdict["addr"] = "x" + configdict["addr"]
|
configdict["addr"] = "x" + configdict["addr"]
|
||||||
ac1.update_config(configdict)
|
ac1.update_config(configdict)
|
||||||
configtracker = ac1.configure()
|
configtracker = ac1.configure()
|
||||||
@@ -3012,7 +3012,7 @@ class TestOnlineConfigureFails:
|
|||||||
|
|
||||||
def test_invalid_domain(self, acfactory):
|
def test_invalid_domain(self, acfactory):
|
||||||
configdict = acfactory.get_next_liveconfig()
|
configdict = acfactory.get_next_liveconfig()
|
||||||
ac1 = acfactory.make_account()
|
ac1 = acfactory.get_unconfigured_account()
|
||||||
configdict["addr"] += "x"
|
configdict["addr"] += "x"
|
||||||
ac1.update_config(configdict)
|
ac1.update_config(configdict)
|
||||||
configtracker = ac1.configure()
|
configtracker = ac1.configure()
|
||||||
|
|||||||
Reference in New Issue
Block a user