Tests package¶
Description
Tests
tests.conftest¶
Test configuration
-
tests.conftest.
bot
()¶ Called at the beginning of the testing session. Starts the bot with the testing setting in another thread
- Yields
None – wait for the testing session to end
-
tests.conftest.
client
(bot) → telethon.client.telegramclient.TelegramClient¶ Called at the beginning of the testing session. Creates the telegram client that will simulate the user
- Yields
Iterator[TelegramClient] – telegram client that will simulate the user
-
tests.conftest.
db_results
() → dict¶ Called at the beginning of the testing session. Creates initializes the database
- Yields
Iterator[dict] – dictionary containing the results for the test queries
-
tests.conftest.
event_loop
()¶ Allows to use @pytest.fixture(scope=”session”) for the folowing functions
- Yields
AbstractEventLoop – loop to be executed
-
tests.conftest.
get_session
()¶ Shows the String session. The string found must be inserted in the settings.yaml file
-
tests.conftest.
start_test_bot
()¶ Starts the bot with the test stettings
tests.test_bot¶
Tests the bot functionality
-
tests.test_bot.
get_telegram_md
(message_text: str) → str¶ Gets the message received from the bot and reverts it to the Markdowm_v2 used to send messages with it
- Parameters
message_text (str) – text of the message received from the bot
- Returns
the same text of the message, but with the Markdown_v2 conventions
- Return type
str
-
tests.test_bot.
teardown
()¶ Makes so that there is a fixed timeout between each test
-
async
tests.test_bot.
test_help_cmd
(client: telethon.client.telegramclient.TelegramClient)¶ Tests the help command
- Parameters
client (TelegramClient) – client used to simulate the user
-
async
tests.test_bot.
test_post_conversation
(client: telethon.client.telegramclient.TelegramClient)¶ Tests the whole flow of the create conversation with the default image The image creation is handled by the main thread
- Parameters
client (TelegramClient) – client used to simulate the user
-
async
tests.test_bot.
test_rules_cmd
(client: telethon.client.telegramclient.TelegramClient)¶ Tests the rules command
- Parameters
client (TelegramClient) – client used to simulate the user
-
async
tests.test_bot.
test_start_cmd
(client: telethon.client.telegramclient.TelegramClient)¶ Tests the start command
- Parameters
client (TelegramClient) – client used to simulate the user
tests.test_db¶
Test all the modules related to data management
-
tests.test_db.
query_to_string
(query_result: list) → list¶ Converts a query result in a well formatted list of rows
- Parameters
query_result (list) – query result to be converted
- Returns
the corrisponding list of rows
- Return type
list
-
tests.test_db.
test_count_from
(db_results)¶ Tests the count_from function of the database
-
tests.test_db.
test_delete_from
(db_results)¶ Tests the delete_from function of the database
-
tests.test_db.
test_get_db
(db_results)¶ Tests the get_db function for the database
-
tests.test_db.
test_insert_into
(db_results)¶ Tests the insert_into function of the database
-
tests.test_db.
test_query_from_string
(db_results)¶ Tests the query_from_string function for the database
-
tests.test_db.
test_select_from
(db_results)¶ Tests the select_from function of the database