create basic loop which checks whether a new day started

This commit is contained in:
missytake 2023-09-01 14:42:55 +02:00
parent 726f9421ea
commit a328c255af
3 changed files with 30 additions and 1 deletions

View file

@ -27,7 +27,7 @@ where = src
[options.entry_points]
console_scripts =
remember-remember-bot = remember_remember_bot.cli:main
remember-remember-bot = remember_remember_bot.loop:loop
[tox:tox]
envlist = lint, py310

View file

@ -0,0 +1,21 @@
import time
import datetime
def loop():
current_day = 0
while True:
if check_new_day(current_day):
pass
print(current_day)
current_day = update_day()
time.sleep(1)
def check_new_day(current_day):
if current_day == datetime.datetime.now().day:
return True
def update_day():
return datetime.datetime.now().day

8
tests/test_loop.py Normal file
View file

@ -0,0 +1,8 @@
from remember_remember_bot.loop import check_new_day, update_day
def test_update_day() -> None:
current_day = 0
assert check_new_day(current_day)
current_day = update_day()
assert not check_new_day(current_day)