mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 05:16:28 +03:00
add configure-failure tests
This commit is contained in:
@@ -150,7 +150,7 @@ def acfactory(pytestconfig, tmpdir, request, session_liveconfig):
|
|||||||
lib.dc_set_config(ac._dc_context, b"configured", b"1")
|
lib.dc_set_config(ac._dc_context, b"configured", b"1")
|
||||||
return ac
|
return ac
|
||||||
|
|
||||||
def get_online_configuring_account(self):
|
def get_online_config(self):
|
||||||
if not session_liveconfig:
|
if not session_liveconfig:
|
||||||
pytest.skip("specify DCC_PY_LIVECONFIG or --liveconfig")
|
pytest.skip("specify DCC_PY_LIVECONFIG or --liveconfig")
|
||||||
configdict = session_liveconfig.get(self.live_count)
|
configdict = session_liveconfig.get(self.live_count)
|
||||||
@@ -161,6 +161,10 @@ def acfactory(pytestconfig, tmpdir, request, session_liveconfig):
|
|||||||
ac = self.make_account(tmpdb.strpath, logid="ac{}".format(self.live_count))
|
ac = self.make_account(tmpdb.strpath, logid="ac{}".format(self.live_count))
|
||||||
ac._evlogger.init_time = self.init_time
|
ac._evlogger.init_time = self.init_time
|
||||||
ac._evlogger.set_timeout(30)
|
ac._evlogger.set_timeout(30)
|
||||||
|
return ac, configdict
|
||||||
|
|
||||||
|
def get_online_configuring_account(self):
|
||||||
|
ac, configdict = self.get_online_config()
|
||||||
ac.configure(**configdict)
|
ac.configure(**configdict)
|
||||||
ac.start_threads()
|
ac.start_threads()
|
||||||
return ac
|
return ac
|
||||||
@@ -206,12 +210,13 @@ def lp():
|
|||||||
return Printer()
|
return Printer()
|
||||||
|
|
||||||
|
|
||||||
def wait_configuration_progress(account, target):
|
def wait_configuration_progress(account, min_target, max_target=1001):
|
||||||
|
min_target = min(min_target, max_target)
|
||||||
while 1:
|
while 1:
|
||||||
evt_name, data1, data2 = \
|
evt_name, data1, data2 = \
|
||||||
account._evlogger.get_matching("DC_EVENT_CONFIGURE_PROGRESS")
|
account._evlogger.get_matching("DC_EVENT_CONFIGURE_PROGRESS")
|
||||||
if data1 >= target:
|
if data1 >= min_target and data1 <= max_target:
|
||||||
print("** CONFIG PROGRESS {}".format(target), account)
|
print("** CONFIG PROGRESS {}".format(min_target), account)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -616,3 +616,38 @@ class TestOnlineAccount:
|
|||||||
chat1b = ac1.create_chat_by_message(ev[2])
|
chat1b = ac1.create_chat_by_message(ev[2])
|
||||||
assert chat1b.get_profile_image() is None
|
assert chat1b.get_profile_image() is None
|
||||||
assert chat.get_profile_image() is None
|
assert chat.get_profile_image() is None
|
||||||
|
|
||||||
|
|
||||||
|
class TestOnlineConfigureFails:
|
||||||
|
def test_invalid_password(self, acfactory):
|
||||||
|
ac1, configdict = acfactory.get_online_config()
|
||||||
|
pw = configdict["mail_pw"]
|
||||||
|
configdict["mail_pw"] = pw[:-1] # wrong password
|
||||||
|
ac1.configure(**configdict)
|
||||||
|
ac1.start_threads()
|
||||||
|
wait_configuration_progress(ac1, 500)
|
||||||
|
ev1 = ac1._evlogger.get_matching("DC_EVENT_ERROR_NETWORK")
|
||||||
|
assert "authentication failed" in ev1[2].lower()
|
||||||
|
wait_configuration_progress(ac1, 0, 0)
|
||||||
|
|
||||||
|
def test_invalid_user(self, acfactory):
|
||||||
|
ac1, configdict = acfactory.get_online_config()
|
||||||
|
addr = configdict["addr"]
|
||||||
|
configdict["addr"] = "x" + addr # wrong user
|
||||||
|
ac1.configure(**configdict)
|
||||||
|
ac1.start_threads()
|
||||||
|
wait_configuration_progress(ac1, 500)
|
||||||
|
ev1 = ac1._evlogger.get_matching("DC_EVENT_ERROR_NETWORK")
|
||||||
|
assert "authentication failed" in ev1[2].lower()
|
||||||
|
wait_configuration_progress(ac1, 0, 0)
|
||||||
|
|
||||||
|
def test_invalid_domain(self, acfactory):
|
||||||
|
ac1, configdict = acfactory.get_online_config()
|
||||||
|
addr = configdict["addr"]
|
||||||
|
configdict["addr"] = addr + "x"
|
||||||
|
ac1.configure(**configdict)
|
||||||
|
ac1.start_threads()
|
||||||
|
wait_configuration_progress(ac1, 500)
|
||||||
|
ev1 = ac1._evlogger.get_matching("DC_EVENT_ERROR_NETWORK")
|
||||||
|
assert "could not connect" in ev1[2].lower()
|
||||||
|
wait_configuration_progress(ac1, 0, 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user