mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
refine test support function name
This commit is contained in:
@@ -273,10 +273,9 @@ class ACFactory:
|
|||||||
else:
|
else:
|
||||||
print("WARN: could not use preconfigured keys for {!r}".format(addr))
|
print("WARN: could not use preconfigured keys for {!r}".format(addr))
|
||||||
|
|
||||||
def get_configured_offline_account(self):
|
def get_pseudo_configured_account(self):
|
||||||
ac = self.get_unconfigured_account()
|
|
||||||
|
|
||||||
# do a pseudo-configured account
|
# do a pseudo-configured account
|
||||||
|
ac = self.get_unconfigured_account()
|
||||||
acname = os.path.basename(ac.db_path)
|
acname = os.path.basename(ac.db_path)
|
||||||
addr = "{}@offline.org".format(acname)
|
addr = "{}@offline.org".format(acname)
|
||||||
ac.update_config(dict(
|
ac.update_config(dict(
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ class TestOfflineAccountBasic:
|
|||||||
assert not ac1.get_self_contact().addr
|
assert not ac1.get_self_contact().addr
|
||||||
|
|
||||||
def test_selfcontact_configured(self, acfactory):
|
def test_selfcontact_configured(self, acfactory):
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
me = ac1.get_self_contact()
|
me = ac1.get_self_contact()
|
||||||
assert me.display_name
|
assert me.display_name
|
||||||
assert me.addr
|
assert me.addr
|
||||||
@@ -121,14 +121,14 @@ class TestOfflineAccountBasic:
|
|||||||
ac1.get_config("123123")
|
ac1.get_config("123123")
|
||||||
|
|
||||||
def test_empty_group_bcc_self_enabled(self, acfactory):
|
def test_empty_group_bcc_self_enabled(self, acfactory):
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
ac1.set_config("bcc_self", "1")
|
ac1.set_config("bcc_self", "1")
|
||||||
chat = ac1.create_group_chat(name="group1")
|
chat = ac1.create_group_chat(name="group1")
|
||||||
msg = chat.send_text("msg1")
|
msg = chat.send_text("msg1")
|
||||||
assert msg in chat.get_messages()
|
assert msg in chat.get_messages()
|
||||||
|
|
||||||
def test_empty_group_bcc_self_disabled(self, acfactory):
|
def test_empty_group_bcc_self_disabled(self, acfactory):
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
ac1.set_config("bcc_self", "0")
|
ac1.set_config("bcc_self", "0")
|
||||||
chat = ac1.create_group_chat(name="group1")
|
chat = ac1.create_group_chat(name="group1")
|
||||||
msg = chat.send_text("msg1")
|
msg = chat.send_text("msg1")
|
||||||
@@ -137,7 +137,7 @@ class TestOfflineAccountBasic:
|
|||||||
|
|
||||||
class TestOfflineContact:
|
class TestOfflineContact:
|
||||||
def test_contact_attr(self, acfactory):
|
def test_contact_attr(self, acfactory):
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
contact1 = ac1.create_contact("some1@example.org", name="some1")
|
contact1 = ac1.create_contact("some1@example.org", name="some1")
|
||||||
contact2 = ac1.create_contact("some1@example.org", name="some1")
|
contact2 = ac1.create_contact("some1@example.org", name="some1")
|
||||||
str(contact1)
|
str(contact1)
|
||||||
@@ -150,7 +150,7 @@ class TestOfflineContact:
|
|||||||
assert not contact1.is_verified()
|
assert not contact1.is_verified()
|
||||||
|
|
||||||
def test_get_blocked(self, acfactory):
|
def test_get_blocked(self, acfactory):
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
contact1 = ac1.create_contact("some1@example.org", name="some1")
|
contact1 = ac1.create_contact("some1@example.org", name="some1")
|
||||||
contact2 = ac1.create_contact("some2@example.org", name="some2")
|
contact2 = ac1.create_contact("some2@example.org", name="some2")
|
||||||
ac1.create_contact("some3@example.org", name="some3")
|
ac1.create_contact("some3@example.org", name="some3")
|
||||||
@@ -164,12 +164,12 @@ class TestOfflineContact:
|
|||||||
assert ac1.get_blocked_contacts() == [contact1]
|
assert ac1.get_blocked_contacts() == [contact1]
|
||||||
|
|
||||||
def test_create_self_contact(self, acfactory):
|
def test_create_self_contact(self, acfactory):
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
contact1 = ac1.create_contact(ac1.get_config("addr"))
|
contact1 = ac1.create_contact(ac1.get_config("addr"))
|
||||||
assert contact1.id == 1
|
assert contact1.id == 1
|
||||||
|
|
||||||
def test_get_contacts_and_delete(self, acfactory):
|
def test_get_contacts_and_delete(self, acfactory):
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
contact1 = ac1.create_contact("some1@example.org", name="some1")
|
contact1 = ac1.create_contact("some1@example.org", name="some1")
|
||||||
contacts = ac1.get_contacts()
|
contacts = ac1.get_contacts()
|
||||||
assert len(contacts) == 1
|
assert len(contacts) == 1
|
||||||
@@ -184,15 +184,15 @@ class TestOfflineContact:
|
|||||||
assert contact1 not in ac1.get_contacts()
|
assert contact1 not in ac1.get_contacts()
|
||||||
|
|
||||||
def test_get_contacts_and_delete_fails(self, acfactory):
|
def test_get_contacts_and_delete_fails(self, acfactory):
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
contact1 = ac1.create_contact("some1@example.com", name="some1")
|
contact1 = ac1.create_contact("some1@example.com", name="some1")
|
||||||
msg = contact1.create_chat().send_text("one message")
|
msg = contact1.create_chat().send_text("one message")
|
||||||
assert not ac1.delete_contact(contact1)
|
assert not ac1.delete_contact(contact1)
|
||||||
assert not msg.filemime
|
assert not msg.filemime
|
||||||
|
|
||||||
def test_create_chat_flexibility(self, acfactory):
|
def test_create_chat_flexibility(self, acfactory):
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
ac2 = acfactory.get_configured_offline_account()
|
ac2 = acfactory.get_pseudo_configured_account()
|
||||||
chat1 = ac1.create_chat(ac2)
|
chat1 = ac1.create_chat(ac2)
|
||||||
chat2 = ac1.create_chat(ac2.get_self_contact().addr)
|
chat2 = ac1.create_chat(ac2.get_self_contact().addr)
|
||||||
assert chat1 == chat2
|
assert chat1 == chat2
|
||||||
@@ -201,7 +201,7 @@ class TestOfflineContact:
|
|||||||
ac1.create_chat(ac3)
|
ac1.create_chat(ac3)
|
||||||
|
|
||||||
def test_contact_rename(self, acfactory):
|
def test_contact_rename(self, acfactory):
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
contact = ac1.create_contact("some1@example.com", name="some1")
|
contact = ac1.create_contact("some1@example.com", name="some1")
|
||||||
chat = ac1.create_chat(contact)
|
chat = ac1.create_chat(contact)
|
||||||
assert chat.get_name() == "some1"
|
assert chat.get_name() == "some1"
|
||||||
@@ -214,7 +214,7 @@ class TestOfflineContact:
|
|||||||
class TestOfflineChat:
|
class TestOfflineChat:
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def ac1(self, acfactory):
|
def ac1(self, acfactory):
|
||||||
return acfactory.get_configured_offline_account()
|
return acfactory.get_pseudo_configured_account()
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def chat1(self, ac1):
|
def chat1(self, ac1):
|
||||||
@@ -248,8 +248,8 @@ class TestOfflineChat:
|
|||||||
pytest.fail("could not find chat")
|
pytest.fail("could not find chat")
|
||||||
|
|
||||||
def test_group_chat_add_second_account(self, acfactory):
|
def test_group_chat_add_second_account(self, acfactory):
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
ac2 = acfactory.get_configured_offline_account()
|
ac2 = acfactory.get_pseudo_configured_account()
|
||||||
chat = ac1.create_group_chat(name="title1")
|
chat = ac1.create_group_chat(name="title1")
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
chat.add_contact(ac2.get_self_contact())
|
chat.add_contact(ac2.get_self_contact())
|
||||||
@@ -302,7 +302,7 @@ class TestOfflineChat:
|
|||||||
|
|
||||||
@pytest.mark.parametrize("verified", [True, False])
|
@pytest.mark.parametrize("verified", [True, False])
|
||||||
def test_group_chat_qr(self, acfactory, ac1, verified):
|
def test_group_chat_qr(self, acfactory, ac1, verified):
|
||||||
ac2 = acfactory.get_configured_offline_account()
|
ac2 = acfactory.get_pseudo_configured_account()
|
||||||
chat = ac1.create_group_chat(name="title1", verified=verified)
|
chat = ac1.create_group_chat(name="title1", verified=verified)
|
||||||
assert chat.is_group()
|
assert chat.is_group()
|
||||||
qr = chat.get_join_qr()
|
qr = chat.get_join_qr()
|
||||||
@@ -448,7 +448,7 @@ class TestOfflineChat:
|
|||||||
assert msg2.filename != msg.filename
|
assert msg2.filename != msg.filename
|
||||||
|
|
||||||
def test_create_contact(self, acfactory):
|
def test_create_contact(self, acfactory):
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
email = "hello <hello@example.org>"
|
email = "hello <hello@example.org>"
|
||||||
contact1 = ac1.create_contact(email)
|
contact1 = ac1.create_contact(email)
|
||||||
assert contact1.addr == "hello@example.org"
|
assert contact1.addr == "hello@example.org"
|
||||||
@@ -459,7 +459,7 @@ class TestOfflineChat:
|
|||||||
assert contact2.name == "real"
|
assert contact2.name == "real"
|
||||||
|
|
||||||
def test_create_chat_simple(self, acfactory):
|
def test_create_chat_simple(self, acfactory):
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
contact1 = ac1.create_contact("some1@example.org", name="some1")
|
contact1 = ac1.create_contact("some1@example.org", name="some1")
|
||||||
contact1.create_chat().send_text("hello")
|
contact1.create_chat().send_text("hello")
|
||||||
|
|
||||||
@@ -481,7 +481,7 @@ class TestOfflineChat:
|
|||||||
|
|
||||||
def test_import_export_one_contact(self, acfactory, tmpdir):
|
def test_import_export_one_contact(self, acfactory, tmpdir):
|
||||||
backupdir = tmpdir.mkdir("backup")
|
backupdir = tmpdir.mkdir("backup")
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
chat = ac1.create_contact("some1 <some1@example.org>").create_chat()
|
chat = ac1.create_contact("some1 <some1@example.org>").create_chat()
|
||||||
# send a text message
|
# send a text message
|
||||||
msg = chat.send_text("msg1")
|
msg = chat.send_text("msg1")
|
||||||
@@ -520,8 +520,8 @@ class TestOfflineChat:
|
|||||||
assert chat1.get_draft() is None
|
assert chat1.get_draft() is None
|
||||||
|
|
||||||
def test_qr_setup_contact(self, acfactory, lp):
|
def test_qr_setup_contact(self, acfactory, lp):
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
ac2 = acfactory.get_configured_offline_account()
|
ac2 = acfactory.get_pseudo_configured_account()
|
||||||
qr = ac1.get_setup_contact_qr()
|
qr = ac1.get_setup_contact_qr()
|
||||||
assert qr.startswith("OPENPGP4FPR:")
|
assert qr.startswith("OPENPGP4FPR:")
|
||||||
res = ac2.check_qr(qr)
|
res = ac2.check_qr(qr)
|
||||||
|
|||||||
@@ -68,8 +68,7 @@ def test_sig():
|
|||||||
|
|
||||||
|
|
||||||
def test_markseen_invalid_message_ids(acfactory):
|
def test_markseen_invalid_message_ids(acfactory):
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
|
|
||||||
contact1 = ac1.create_contact("some1@example.com", name="some1")
|
contact1 = ac1.create_contact("some1@example.com", name="some1")
|
||||||
chat = contact1.create_chat()
|
chat = contact1.create_chat()
|
||||||
chat.send_text("one messae")
|
chat.send_text("one messae")
|
||||||
@@ -80,7 +79,7 @@ def test_markseen_invalid_message_ids(acfactory):
|
|||||||
|
|
||||||
|
|
||||||
def test_get_special_message_id_returns_empty_message(acfactory):
|
def test_get_special_message_id_returns_empty_message(acfactory):
|
||||||
ac1 = acfactory.get_configured_offline_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
for i in range(1, 10):
|
for i in range(1, 10):
|
||||||
msg = ac1.get_message_by_id(i)
|
msg = ac1.get_message_by_id(i)
|
||||||
assert msg.id == 0
|
assert msg.id == 0
|
||||||
|
|||||||
Reference in New Issue
Block a user