add a test echo_and_quit examples

This commit is contained in:
holger krekel
2020-03-03 18:55:19 +01:00
parent 91cdc76414
commit f61b9f7964
8 changed files with 106 additions and 57 deletions

View File

@@ -0,0 +1,41 @@
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()