fixxed pipisa

This commit is contained in:
Simple_Not 2023-07-16 01:50:12 +10:00
parent 76d14126a1
commit e8190a500d
4 changed files with 84 additions and 3 deletions

0
__init__.py Normal file
View File

View File

@ -6,6 +6,7 @@ import random
from random import randint
import datetime
from dicktxt import ForReadDict
from pipisa_functions import pipisa_time
#### https://docs.python-arango.com/en/main/
@ -60,10 +61,13 @@ async def up_dick(message: types.Message):
user = candidate_cursor.pop()
last_time = datetime.datetime.strptime(user['datetimes'], '%Y-%m-%d %H:%M:%S')
time_to_grow = datetime.datetime.now().replace(hour=14, minute=8, second=8, microsecond=0) #+ datetime.timedelta(days=0)
# last_time = datetime.datetime.strptime(user['datetimes'], '%Y-%m-%d %H:%M:%S')
# time_to_grow = datetime.datetime.now().replace(hour=14, minute=8, second=8, microsecond=0) #+ datetime.timedelta(days=0)
if (time_to_grow - last_time).total_seconds() > 0:
# if (time_to_grow - last_time).total_seconds() > 0:
if pipisa_time.rolltime(check_datetime=user['datetimes']):
# пришло время крутить!!
updetedDick = user["dick_size"] + numb

View File

@ -0,0 +1 @@
from . import pipisa_time

View File

@ -0,0 +1,76 @@
import unittest
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)
timediff = (time_to_grow - last_time).total_seconds()
# print(f'\tlast_time : {last_time}')
# print(f'\ttime_to_grow : {time_to_grow}')
# print(f'\tcurr_time : {curr_time.strftime("%Y-%m-%d %H:%M:%S")}')
# print(f'\t\tsecs diff : {timediff}')
if timediff > 86400 or curr_time > time_to_grow:
return True
else:
return False
class TestPipisa(unittest.TestCase):
def test_very_long_ago(self):
self.assertEqual(rolltime('2021-10-11 23:44:00'), True, "Пиписа прокручена очень давно. Очевидный прокрут")
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')
), 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)
).strftime('%Y-%m-%d %H:%M:%S'),
datetime.datetime.now().replace(hour=14, minute=9, second=8, microsecond=0)
), True, "Крутилась вчера через минуту после обновления роллов. Должно пропускать ")
def test_hour_before_roll(self):
self.assertEqual(
rolltime(
(
datetime.datetime.now().replace(hour=14, minute=9, second=8, 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)
), 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)
).strftime('%Y-%m-%d %H:%M:%S'),
datetime.datetime.now().replace(hour=0, minute=11, second=8, microsecond=0)
), False, "Где-то ночью прокручивается повторно. Фейл.")
def test_before_midnight(self):
self.assertEqual(
rolltime(
(
datetime.datetime.now().replace(hour=14, minute=9, second=8, 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, "Где-то ночью прокручивается повторно. Фейл.")
if __name__ == "__main__":
unittest.main()