chore: specify dev dependencies in setup.cfg, add CI (#12)
* chore: specify dev dependencies in setup.cfg * added CI * fix lint * fix flaky test
This commit is contained in:
parent
f3daeee8d9
commit
18e5a67aa7
23
.github/workflows/ci.yml
vendored
Normal file
23
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ['3.8', '3.11']
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
python -m pip install '.[dev]'
|
||||||
|
- run: tox
|
||||||
|
|
|
@ -103,7 +103,6 @@ run:
|
||||||
```
|
```
|
||||||
python3 -m venv venv
|
python3 -m venv venv
|
||||||
. venv/bin/activate
|
. venv/bin/activate
|
||||||
pip install pytest tox black pytest-xdist pytest-timeout
|
pip install -e .[dev]
|
||||||
pip install -e .
|
|
||||||
tox
|
tox
|
||||||
```
|
```
|
||||||
|
|
|
@ -26,6 +26,14 @@ install_requires =
|
||||||
qrcode
|
qrcode
|
||||||
deltachat>=1.136.2
|
deltachat>=1.136.2
|
||||||
|
|
||||||
|
[options.extras_require]
|
||||||
|
dev =
|
||||||
|
pytest
|
||||||
|
tox
|
||||||
|
black
|
||||||
|
pytest-xdist
|
||||||
|
pytest-timeout
|
||||||
|
|
||||||
[options.packages.find]
|
[options.packages.find]
|
||||||
where = src
|
where = src
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,7 @@ from pyinfra import host
|
||||||
from pyinfra.facts.systemd import SystemdStatus
|
from pyinfra.facts.systemd import SystemdStatus
|
||||||
|
|
||||||
|
|
||||||
def deploy_team_bot(
|
def deploy_team_bot(unix_user: str, bot_email: str, bot_passwd: str, dbdir: str = None):
|
||||||
unix_user: str, bot_email: str, bot_passwd: str, dbdir: str = None
|
|
||||||
):
|
|
||||||
"""Deploy TeamsBot to a UNIX user, with specified credentials
|
"""Deploy TeamsBot to a UNIX user, with specified credentials
|
||||||
|
|
||||||
:param unix_user: the existing UNIX user of the bot
|
:param unix_user: the existing UNIX user of the bot
|
||||||
|
|
|
@ -6,7 +6,7 @@ import pytest
|
||||||
from deltachat.capi import lib as dclib
|
from deltachat.capi import lib as dclib
|
||||||
|
|
||||||
|
|
||||||
TIMEOUT = 20
|
TIMEOUT = 40
|
||||||
|
|
||||||
|
|
||||||
def get_user_crew(crewuser: deltachat.Account) -> deltachat.Chat:
|
def get_user_crew(crewuser: deltachat.Account) -> deltachat.Chat:
|
||||||
|
@ -27,38 +27,57 @@ def test_not_relay_groups(relaycrew, outsider, lp):
|
||||||
bot = relaycrew.bot
|
bot = relaycrew.bot
|
||||||
user = relaycrew.user
|
user = relaycrew.user
|
||||||
|
|
||||||
lp.sec("bot <-> outsider 1:1 chat")
|
text = "outsider -> bot 1:1 chat"
|
||||||
|
lp.sec(text)
|
||||||
outsider_botcontact = outsider.create_contact(bot.get_config("addr"))
|
outsider_botcontact = outsider.create_contact(bot.get_config("addr"))
|
||||||
outsider_outside_chat = outsider.create_chat(outsider_botcontact)
|
outsider_outside_chat = outsider.create_chat(outsider_botcontact)
|
||||||
outsider_outside_chat.send_text("test 1:1 message to bot")
|
outsider_outside_chat.send_text(text)
|
||||||
|
lp.sec("receiving message from outsider in 1:1 chat")
|
||||||
bot_message_from_outsider = bot._evtracker.wait_next_incoming_message()
|
bot_message_from_outsider = bot._evtracker.wait_next_incoming_message()
|
||||||
bot_outside_chat = bot_message_from_outsider.chat
|
bot_outside_chat = bot_message_from_outsider.chat
|
||||||
|
assert bot_message_from_outsider.text == text
|
||||||
assert not bot.relayplugin.is_relay_group(bot_outside_chat)
|
assert not bot.relayplugin.is_relay_group(bot_outside_chat)
|
||||||
|
|
||||||
lp.sec("bot <-> outsider group chat")
|
text = "outsider -> bot group chat"
|
||||||
|
lp.sec(text)
|
||||||
outsider_bot_group = outsider.create_group_chat(
|
outsider_bot_group = outsider.create_group_chat(
|
||||||
"test with outsider", contacts=[outsider_botcontact]
|
"test with outsider", contacts=[outsider_botcontact]
|
||||||
)
|
)
|
||||||
outsider_bot_group.send_text("test message to outsider group")
|
outsider_bot_group.send_text(text)
|
||||||
|
lp.sec("receiving message from outsider in group chat")
|
||||||
bot_message_from_outsider = bot._evtracker.wait_next_incoming_message()
|
bot_message_from_outsider = bot._evtracker.wait_next_incoming_message()
|
||||||
|
assert bot_message_from_outsider.text == text
|
||||||
assert not bot.relayplugin.is_relay_group(bot_message_from_outsider.chat)
|
assert not bot.relayplugin.is_relay_group(bot_message_from_outsider.chat)
|
||||||
|
|
||||||
lp.sec("bot <-> user 1:1 chat")
|
text = "user -> bot 1:1 chat"
|
||||||
|
lp.sec(text)
|
||||||
user_botcontact = user.create_contact(bot.get_config("addr"))
|
user_botcontact = user.create_contact(bot.get_config("addr"))
|
||||||
user_to_bot = user.create_chat(user_botcontact)
|
user_to_bot = user.create_chat(user_botcontact)
|
||||||
user_to_bot.send_text("test message to bot")
|
user_to_bot.send_text(text)
|
||||||
|
lp.sec("receiving message from user in 1:1 chat")
|
||||||
|
|
||||||
# somehow the message doesn't trigger DC_EVENT_INCOMING_MSG
|
# somehow the message doesn't trigger DC_EVENT_INCOMING_MSG
|
||||||
bot_message_from_user = bot.get_chats()[-3].get_messages()[-1] # bot._evtracker.wait_next_incoming_message()
|
# bot._evtracker.wait_next_incoming_message()
|
||||||
while bot_message_from_user.text != "test message to bot":
|
def find_msg(ac, text):
|
||||||
bot_message_from_user = bot.get_chats()[-3].get_messages()[-1] # bot._evtracker.wait_next_incoming_message()
|
for chat in ac.get_chats():
|
||||||
|
for msg in chat.get_messages():
|
||||||
|
if msg.text == text:
|
||||||
|
return msg
|
||||||
|
|
||||||
|
bot_message_from_user = find_msg(bot, text)
|
||||||
|
while not bot_message_from_user:
|
||||||
|
bot_message_from_user = find_msg(bot, text)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
assert bot_message_from_user.text == text
|
||||||
assert not bot.relayplugin.is_relay_group(bot_message_from_user.chat)
|
assert not bot.relayplugin.is_relay_group(bot_message_from_user.chat)
|
||||||
|
|
||||||
lp.sec("bot <-> user group chat")
|
text = "user -> bot group chat"
|
||||||
|
lp.sec(text)
|
||||||
user_group = user.create_group_chat("test with user", contacts=[user_botcontact])
|
user_group = user.create_group_chat("test with user", contacts=[user_botcontact])
|
||||||
user_group.send_text("testing message to user group")
|
user_group.send_text(text)
|
||||||
|
lp.sec("receiving message from user in group chat")
|
||||||
bot_message_from_user = bot._evtracker.wait_next_incoming_message()
|
bot_message_from_user = bot._evtracker.wait_next_incoming_message()
|
||||||
|
assert bot_message_from_user.text == text
|
||||||
assert not bot.relayplugin.is_relay_group(bot_message_from_user.chat)
|
assert not bot.relayplugin.is_relay_group(bot_message_from_user.chat)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue