remember-remember-bot/tests/test_util.py

41 lines
1 KiB
Python
Raw Normal View History

2023-09-01 15:01:03 +00:00
from remember_remember_bot.util import (
check_new_day,
update_day,
chat_is_active,
get_file_path,
)
import pytest
def test_update_day():
current_day = 0
assert check_new_day(current_day)
current_day = update_day()
assert not check_new_day(current_day)
@pytest.mark.parametrize(
("messages", "active"),
[
(["/start"], True),
(["/start", "/stop"], False),
(["/start", "/stop", "Let's get this party started"], False),
(["/start", "/stop", "/start"], True),
],
)
def test_chat_is_active(messages, active):
assert chat_is_active(messages) == active
@pytest.mark.parametrize(
("messages", "file_path"),
[
(["/file /home/user/test"], "/home/user/test"),
(["/file /home/user/test", "/stop"], "/home/user/test"),
(["I stored your reminders at the file /home/user/test"], "/home/user/test"),
(["/start", "/stop", "/start"], None),
],
)
def test_get_file_path(messages: [], file_path: str):
assert get_file_path(messages) == file_path