forked from UNICT-DMI/Telegram-DMI-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests in separated files (UNICT-DMI#176)
* fix: remove useless duplicated test file * refactor: tests splitted * fix: markdown error for user with underscore * test: adds for nested buttons in help command * fix(test): sleep for profs 'cause multiple messages * fix(test): rappresentati button in help command * style(black): skip replacing of single-quote when formats * tests: assert response text with real expected text * tests(aulario): right/left buttons in calendar * fix: rappr button after UNICT-DMI#173
- Loading branch information
Showing
15 changed files
with
423 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[tool.black] | ||
skip-string-normalization = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
"""Module for testing""" | ||
from module.shared import config_map | ||
|
||
TIMEOUT = 8 | ||
bot_tag = config_map['test']['tag'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import calendar | ||
from datetime import datetime | ||
|
||
import pytest | ||
from telethon.sync import TelegramClient | ||
from telethon.tl.custom.conversation import Conversation | ||
from telethon.tl.custom.message import Message | ||
|
||
from . import TIMEOUT, bot_tag | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_aulario_cmd(client: TelegramClient): | ||
"""Tests the /aulario command | ||
Args: | ||
client (TelegramClient): client used to simulate the user | ||
""" | ||
conv: Conversation | ||
async with client.conversation(bot_tag, timeout=TIMEOUT) as conv: | ||
|
||
await conv.send_message("/aulario") # send a command | ||
resp: Message = await conv.get_response() | ||
|
||
assert resp.text == 'Seleziona la data della lezione che ti interessa.' | ||
|
||
if "⚠️" in resp.text: | ||
return | ||
|
||
now = datetime.now() | ||
|
||
await resp.click(text=f"{now.day}") # click the button | ||
resp: Message = await conv.get_response() | ||
assert resp.text | ||
|
||
await resp.click(data="sm_aulario") # click the button | ||
resp = await conv.get_edit() | ||
assert resp.text | ||
|
||
await resp.click( | ||
text="{} ▶️".format(calendar.month_name[((now.month % 12) + 1)]) | ||
) | ||
resp = await conv.get_edit() | ||
assert resp.text | ||
|
||
await resp.click( | ||
text="{} ▶️".format(calendar.month_name[((now.month % 12) + 2)]) | ||
) | ||
resp = await conv.get_edit() | ||
assert resp.text | ||
|
||
await resp.click( | ||
text="◀️ {}".format(calendar.month_name[((now.month % 12) + 1)]) | ||
) | ||
resp = await conv.get_edit() | ||
assert resp.text |
Oops, something went wrong.