From 86813583178eaf833a10ab070b879cb2fc8dc625 Mon Sep 17 00:00:00 2001 From: missytake Date: Mon, 29 Apr 2024 20:03:06 +0200 Subject: [PATCH] tests: new helper function to get crew from team member's perspective --- .gitignore | 1 + tests/test_bot.py | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5a386d0..a967a8f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ __pycache__/ /.tox/ /build/ +/dist/ /venv/ bot.db/ teams_bot_data/ diff --git a/tests/test_bot.py b/tests/test_bot.py index fc3c51f..965375c 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -9,6 +9,19 @@ from deltachat.capi import lib as dclib TIMEOUT = 20 +def get_user_crew(crewuser: deltachat.Account) -> deltachat.Chat: + """Get the Team chat from the team member's point of view. + + :param crewuser: the account object of the team member + :return: the chat object of the team chat + """ + for chat in crewuser.get_chats(): + print(chat.id, chat.get_name()) + user_crew = crewuser.get_chat_by_id(11) + assert user_crew.get_name().startswith("Team") + return user_crew + + @pytest.mark.timeout(60) def test_not_relay_groups(relaycrew, outsider): bot = relaycrew.bot @@ -202,10 +215,7 @@ def test_change_avatar(relaycrew): pytest.skip(f"example image not available: {example_png_path}") # set avatar to example image - for chat in user.get_chats(): - print(chat.id, chat.get_name()) - user_crew = user.get_chat_by_id(11) - assert user_crew.get_name().startswith("Team") + user_crew = get_user_crew(user) msg = deltachat.Message.new_empty(user, "image") msg.set_text("/set_avatar") msg.set_file(example_png_path)