Обновить pipisa_functions/pipisa_time.py
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
KazumaSatir 2025-01-03 03:16:23 +10:00
parent 9f7ae4b9a7
commit 43148417c8

View File

@ -1,4 +1,3 @@
import unittest
import datetime
@ -7,7 +6,7 @@ import datetime
def rolltime(check_datetime , curr_time=datetime.datetime.now()):
last_time = datetime.datetime.strptime(check_datetime, '%Y-%m-%d %H:%M:%S')
time_to_grow = curr_time.replace(hour=14, minute=8, second=8, microsecond=0) #+ datetime.timedelta(days=0)
time_to_grow = curr_time.replace(hour=10, minute=0, second=0, microsecond=0) #+ datetime.timedelta(days=0)
timediff = (time_to_grow - last_time).total_seconds()
@ -31,16 +30,16 @@ class TestPipisa(unittest.TestCase):
def test_just_after(self):
self.assertEqual(rolltime(
datetime.datetime.now().replace(hour=14, minute=9, second=8, microsecond=0).strftime('%Y-%m-%d %H:%M:%S')
datetime.datetime.now().replace(hour=10, minute=1, second=0, microsecond=0).strftime('%Y-%m-%d %H:%M:%S')
), False, "Попытка крутить когда старый прокрут был через 1 минуту после сегодняшнего обновления роллов. Фейл.")
def test_yesterdayroll(self):
self.assertEqual(
rolltime(
(
datetime.datetime.now().replace(hour=14, minute=9, second=8, microsecond=0) - datetime.timedelta(days=1)
datetime.datetime.now().replace(hour=10, minute=1, second=0, microsecond=0) - datetime.timedelta(days=1)
).strftime('%Y-%m-%d %H:%M:%S'),
datetime.datetime.now().replace(hour=14, minute=9, second=8, microsecond=0)
datetime.datetime.now().replace(hour=10, minute=1, second=0, microsecond=0)
), True, "Крутилась вчера через минуту после обновления роллов. Должно пропускать ")
@ -48,16 +47,16 @@ class TestPipisa(unittest.TestCase):
self.assertEqual(
rolltime(
(
datetime.datetime.now().replace(hour=14, minute=9, second=8, microsecond=0) - datetime.timedelta(hours=1)
datetime.datetime.now().replace(hour=10, minute=1, second=1, microsecond=0) - datetime.timedelta(hours=1)
).strftime('%Y-%m-%d %H:%M:%S'),
datetime.datetime.now().replace(hour=14, minute=9, second=8, microsecond=0)
datetime.datetime.now().replace(hour=10, minute=1, second=0, microsecond=0)
), True, "Крутилась последний раз за час до прокрута. Надо разрешать заново!")
def test_after_midnight(self):
self.assertEqual(
rolltime(
(
datetime.datetime.now().replace(hour=14, minute=9, second=8, microsecond=0) - datetime.timedelta(hours=14)
datetime.datetime.now().replace(hour=10, minute=1, second=0, microsecond=0) - datetime.timedelta(hours=14)
).strftime('%Y-%m-%d %H:%M:%S'),
datetime.datetime.now().replace(hour=0, minute=11, second=8, microsecond=0)
), False, "Где-то ночью прокручивается повторно. Фейл.")
@ -66,7 +65,7 @@ class TestPipisa(unittest.TestCase):
self.assertEqual(
rolltime(
(
datetime.datetime.now().replace(hour=14, minute=9, second=8, microsecond=0) - datetime.timedelta(hours=15)
datetime.datetime.now().replace(hour=10, minute=1, second=0, microsecond=0) - datetime.timedelta(hours=15)
).strftime('%Y-%m-%d %H:%M:%S'),
datetime.datetime.now().replace(hour=0, minute=11, second=8, microsecond=0) - datetime.timedelta(hours=15)
), False, "Где-то ночью прокручивается повторно. Фейл.")
@ -75,9 +74,9 @@ class TestPipisa(unittest.TestCase):
self.assertEqual(
rolltime(
(
datetime.datetime.now().replace(hour=14, minute=26, second=8, microsecond=0)
datetime.datetime.now().replace(hour=10, minute=18, second=0, microsecond=0)
).strftime('%Y-%m-%d %H:%M:%S'),
datetime.datetime.now().replace(hour=14, minute=27, second=8, microsecond=0)
datetime.datetime.now().replace(hour=10, minute=19, second=0, microsecond=0)
), False, "Сегодня уже открутили а хотят ещё. Фейл.")