From 43148417c80fb5f8b46b4b42e2369d5bdd0a07f6 Mon Sep 17 00:00:00 2001 From: KazumaSatir Date: Fri, 3 Jan 2025 03:16:23 +1000 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20pipisa=5Ffunctions/pipisa=5Ftime.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pipisa_functions/pipisa_time.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/pipisa_functions/pipisa_time.py b/pipisa_functions/pipisa_time.py index a0f3bcd..5266444 100644 --- a/pipisa_functions/pipisa_time.py +++ b/pipisa_functions/pipisa_time.py @@ -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, "Сегодня уже открутили а хотят ещё. Фейл.")