mirror of
https://github.com/chatmail/core.git
synced 2026-04-06 07:32:12 +03:00
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
|
|
import threading
|
|
import pytest
|
|
import py
|
|
from echo_and_quit import main
|
|
|
|
|
|
@pytest.fixture(scope='session')
|
|
def datadir():
|
|
"""The py.path.local object of the test-data/ directory."""
|
|
for path in reversed(py.path.local(__file__).parts()):
|
|
datadir = path.join('test-data')
|
|
if datadir.isdir():
|
|
return datadir
|
|
else:
|
|
pytest.skip('test-data directory not found')
|
|
|
|
|
|
def test_echo_quit_plugin(acfactory):
|
|
bot_ac, bot_cfg = acfactory.get_online_config()
|
|
|
|
def run_bot():
|
|
print("*"*20 + " starting bot")
|
|
main([
|
|
"-l",
|
|
"--email", bot_cfg["addr"],
|
|
"--password", bot_cfg["mail_pw"],
|
|
"--db", bot_ac.db_path
|
|
])
|
|
|
|
t = threading.Thread(target=run_bot)
|
|
t.start()
|
|
|
|
ac1 = acfactory.get_one_online_account()
|
|
bot_contact = ac1.create_contact(bot_cfg["addr"])
|
|
ch1 = ac1.create_chat_by_contact(bot_contact)
|
|
ch1.send_text("hello")
|
|
reply = ac1._evtracker.wait_next_incoming_message()
|
|
assert "hello" in reply.text
|
|
ch1.send_text("/quit")
|
|
t.join()
|