apply isort and black formatters, add format checking to CI

This commit is contained in:
adbenitez
2022-05-29 21:11:49 -04:00
parent 62b50c87d4
commit 16e0f0e986
26 changed files with 899 additions and 575 deletions

View File

@@ -1,24 +1,25 @@
import os
from queue import Queue
from deltachat import capi, cutil, const
from deltachat import register_global_plugin
from deltachat import capi, const, cutil, register_global_plugin
from deltachat.capi import ffi, lib
from deltachat.hookspec import global_hookimpl
from deltachat.capi import ffi
from deltachat.capi import lib
from deltachat.testplugin import ACSetup, create_dict_from_files_in_path, write_dict_to_dir
from deltachat.testplugin import (
ACSetup,
create_dict_from_files_in_path,
write_dict_to_dir,
)
# from deltachat.account import EventLogger
class TestACSetup:
def test_cache_writing(self, tmp_path):
base = tmp_path.joinpath("hello")
base.mkdir()
d1 = base.joinpath("dir1")
d1.mkdir()
d1.joinpath("file1").write_bytes(b'content1')
d1.joinpath("file1").write_bytes(b"content1")
d2 = d1.joinpath("dir2")
d2.mkdir()
d2.joinpath("file2").write_bytes(b"123")
@@ -42,7 +43,9 @@ class TestACSetup:
pc.bring_online()
assert pc._account2state[acc] == pc.IDLEREADY
def test_two_accounts_one_waited_all_started(self, monkeypatch, acfactory, testprocess):
def test_two_accounts_one_waited_all_started(
self, monkeypatch, acfactory, testprocess
):
pc = ACSetup(init_time=0.0, testprocess=testprocess)
monkeypatch.setattr(pc, "init_imap", lambda *args, **kwargs: None)
monkeypatch.setattr(pc, "_onconfigure_start_io", lambda *args, **kwargs: None)
@@ -103,6 +106,7 @@ def test_dc_close_events(tmpdir, acfactory):
def dc_account_after_shutdown(self, account):
assert account._dc_context is None
shutdowns.put(account)
register_global_plugin(ShutdownPlugin())
assert hasattr(ac1, "_dc_context")
ac1.shutdown()
@@ -168,7 +172,12 @@ def test_provider_info_none():
lib.dc_context_new(ffi.NULL, ffi.NULL, ffi.NULL),
lib.dc_context_unref,
)
assert lib.dc_provider_new_from_email(ctx, cutil.as_dc_charpointer("email@unexistent.no")) == ffi.NULL
assert (
lib.dc_provider_new_from_email(
ctx, cutil.as_dc_charpointer("email@unexistent.no")
)
== ffi.NULL
)
def test_get_info_open(tmpdir):
@@ -178,8 +187,8 @@ def test_get_info_open(tmpdir):
lib.dc_context_unref,
)
info = cutil.from_dc_charpointer(lib.dc_get_info(ctx))
assert 'deltachat_core_version' in info
assert 'database_dir' in info
assert "deltachat_core_version" in info
assert "database_dir" in info
def test_logged_hook_failure(acfactory):
@@ -187,7 +196,7 @@ def test_logged_hook_failure(acfactory):
cap = []
ac1.log = cap.append
with ac1._event_thread.swallow_and_log_exception("some"):
0/0
0 / 0
assert cap
assert "some" in str(cap)
assert "ZeroDivisionError" in str(cap)
@@ -202,7 +211,7 @@ def test_logged_ac_process_ffi_failure(acfactory):
class FailPlugin:
@account_hookimpl
def ac_process_ffi_event(ffi_event):
0/0
0 / 0
cap = Queue()
ac1.log = cap.put