mirror of
https://gitea.phreedom.club/localhost_frssoft/FMN_bot.git
synced 2024-12-21 11:19:49 +00:00
test date
This commit is contained in:
parent
e415e92d49
commit
e3b0e104ce
9
test.py
9
test.py
@ -8,20 +8,21 @@ class TestDate(unittest.TestCase):
|
|||||||
def test_date_tue(self):
|
def test_date_tue(self):
|
||||||
"""
|
"""
|
||||||
test near tue
|
test near tue
|
||||||
|
тестирует корректность расчета даты на след. вторник
|
||||||
|
условия: расчет начат от воскресенья или понедельника (случайно)
|
||||||
"""
|
"""
|
||||||
import calendar
|
import calendar
|
||||||
import random
|
import random
|
||||||
for month in range(1, 13):
|
for month in range(1, 13):
|
||||||
sundays = [i for i in calendar.Calendar().itermonthdays4(year=2024, month=month) if i[3] == 6]
|
sundays = [i for i in calendar.Calendar().itermonthdays4(year=2024, month=month) if i[3] == 6]
|
||||||
for sunday in sundays:
|
for sunday in sundays:
|
||||||
fake_date = datetime.datetime(year=sunday[0], month=sunday[1], day=sunday[2], hour=random.randint(21, 23))
|
fake_date = datetime.datetime(year=sunday[0], month=sunday[1], day=sunday[2], hour=random.randint(21, 23)) + datetime.timedelta(days=random.randint(0, 1))
|
||||||
with time_machine.travel(fake_date):
|
with time_machine.travel(fake_date):
|
||||||
try:
|
try:
|
||||||
result = sheduler.check_stop_thread_scan(fake_date)
|
result = sheduler.check_stop_thread_scan(fake_date)
|
||||||
print("current fake date: " + fake_date.strftime("%Y.%m.%d %H:%M") + f" near tue: {result}")
|
print("current fake date: " + fake_date.strftime("%Y.%m.%d %H:%M") + f" near tue: {result}")
|
||||||
except:
|
except Exception as E:
|
||||||
print("fail fake date: " + fake_date.strftime("%Y.%m.%d %H:%M"))
|
print("fail fake date: " + fake_date.strftime("%Y.%m.%d %H:%M") + f", err: {E}")
|
||||||
#self.assertEqual(result, datetime.datetime(year=2024, month=7, day=2, hour=16))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user