Reduce the amount of files and functions

This commit is contained in:
2025-02-24 13:52:00 +01:00
parent 2806e6044d
commit 4aa0bd7837
5 changed files with 59 additions and 293 deletions

View File

@ -9,35 +9,12 @@ from apscheduler.triggers.cron import CronTrigger
from apscheduler.triggers.date import DateTrigger
from apscheduler.triggers.interval import IntervalTrigger
from discord_reminder_bot.misc import calc_time, calculate, get_human_time
from discord_reminder_bot.misc import calculate, get_human_time
if TYPE_CHECKING:
from apscheduler.job import Job
def test_calc_time() -> None:
"""Test the calc_time function with various datetime inputs."""
test_datetime: datetime = datetime(2023, 10, 1, 12, 0, 0, tzinfo=timezone.utc)
expected_timestamp: str = f"<t:{int(test_datetime.timestamp())}:R>"
assert_msg = f"Expected {expected_timestamp}, got {calc_time(test_datetime)}"
assert calc_time(test_datetime) == expected_timestamp, assert_msg
now: datetime = datetime.now(tz=timezone.utc)
expected_timestamp_now: str = f"<t:{int(now.timestamp())}:R>"
assert_msg = f"Expected {expected_timestamp_now}, got {calc_time(now)}"
assert calc_time(now) == expected_timestamp_now, assert_msg
past_datetime: datetime = datetime(2000, 1, 1, 0, 0, 0, tzinfo=timezone.utc)
expected_timestamp_past: str = f"<t:{int(past_datetime.timestamp())}:R>"
assert_msg = f"Expected {expected_timestamp_past}, got {calc_time(past_datetime)}"
assert calc_time(past_datetime) == expected_timestamp_past, assert_msg
future_datetime: datetime = datetime(2100, 1, 1, 0, 0, 0, tzinfo=timezone.utc)
expected_timestamp_future: str = f"<t:{int(future_datetime.timestamp())}:R>"
assert_msg: str = f"Expected {expected_timestamp_future}, got {calc_time(future_datetime)}"
assert calc_time(future_datetime) == expected_timestamp_future, assert_msg
def test_get_human_time() -> None:
"""Test the get_human_time function with various timedelta inputs."""
test_timedelta = timedelta(days=1, hours=2, minutes=3, seconds=4)