mirror of
https://github.com/bugsink/bugsink.git
synced 2026-04-26 08:59:53 -05:00
Add a few more tests to _prev_tup
This commit is contained in:
@@ -5,6 +5,12 @@ from unittest import TestCase
|
||||
from bugsink.period_counter import PeriodCounter, _prev_tup
|
||||
|
||||
|
||||
def apply_n(f, n, v):
|
||||
for i in range(n):
|
||||
v = f(v)
|
||||
return v
|
||||
|
||||
|
||||
class PeriodCounterTestCase(TestCase):
|
||||
|
||||
def test_prev_tup(self):
|
||||
@@ -26,6 +32,12 @@ class PeriodCounterTestCase(TestCase):
|
||||
self.assertEquals((2020, 1, 1, 0, 0), _prev_tup((2020, 1, 1, 0, 1)))
|
||||
self.assertEquals((2019, 12, 31, 23, 59), _prev_tup((2020, 1, 1, 0, 0)))
|
||||
|
||||
self.assertEquals((1920,), apply_n(_prev_tup, 100, (2020,)))
|
||||
self.assertEquals((2010, 5), apply_n(_prev_tup, 120, (2020, 5)))
|
||||
self.assertEquals((2019, 5, 7,), apply_n(_prev_tup, 366, (2020, 5, 7)))
|
||||
self.assertEquals((2020, 5, 6, 20,), apply_n(_prev_tup, 24, (2020, 5, 7, 20,)))
|
||||
self.assertEquals((2020, 5, 6, 20, 12), apply_n(_prev_tup, 1440, (2020, 5, 7, 20, 12)))
|
||||
|
||||
def test_foo(self):
|
||||
datetime_utc = datetime.now(timezone.utc) # basically I just want to write this down somewhere
|
||||
pc = PeriodCounter()
|
||||
|
||||
Reference in New Issue
Block a user