def should_squeeze_consequent_stats(self): task = TaskWarrior() task.start('foo', now=datetime.datetime(2021, 12, 31, 8, 0, 0)) task.start('bar', now=datetime.datetime(2021, 12, 31, 8, 2, 0)) task.stop(now=datetime.datetime(2021, 12, 31, 8, 5, 0)) task.start(now=datetime.datetime(2021, 12, 31, 8, 7, 0)) task.start('foo', now=datetime.datetime(2021, 12, 31, 8, 8, 0)) self.assertEqual([(_.passed.total_seconds()/60, _.title) for _ in task.get_stats( stop_datetime=datetime.datetime(2021, 12, 31, 8, 30, 0), squeeze=True, )], [ (2, 'foo'), (3, 'bar'), (1, 'bar'), (22, 'foo'), ]) task.rewrite_history( datetime.datetime(2021, 12, 31, 8, 5, 0), datetime.datetime(2021, 12, 31, 8, 7, 0), ['bar', 'bar'] ) self.assertEqual([(_.passed.total_seconds()/60, _.title) for _ in task.get_stats( stop_datetime=datetime.datetime(2021, 12, 31, 8, 30, 0), squeeze=True, )], [ (2, 'foo'), (6, 'bar'), (22, 'foo'), ]) task.start('foo', now=datetime.datetime(2021, 12, 31, 8, 10, 0)) self.assertEqual([(_.passed.total_seconds()/60, _.title) for _ in task.get_stats( stop_datetime=datetime.datetime(2021, 12, 31, 8, 30, 0), squeeze=True, )], [ (2, 'foo'), (6, 'bar'), (22, 'foo'), ])
def should_collect_entries_to_passed_stats(self): task = TaskWarrior() task.start('foo', now=datetime.datetime(2021, 12, 31, 8, 0, 0)) task.start('bar', now=datetime.datetime(2021, 12, 31, 8, 2, 0)) task.stop(now=datetime.datetime(2021, 12, 31, 8, 5, 0)) task.start(now=datetime.datetime(2021, 12, 31, 8, 7, 0)) task.start('foo', now=datetime.datetime(2021, 12, 31, 8, 8, 0)) self.assertEqual([(_.passed.total_seconds()/60, _.title) for _ in task.get_stats( stop_datetime=datetime.datetime(2021, 12, 31, 8, 30, 0), )], [ (2, 'foo'), (3, 'bar'), (1, 'bar'), (22, 'foo'), ]) self.assertEqual([(_.passed.total_seconds()/60, _.title) for _ in task.get_stats( start_datetime=datetime.datetime(2021, 12, 31, 7, 30, 0), stop_datetime=datetime.datetime(2021, 12, 31, 8, 30, 0), )], [ (2, 'foo'), (3, 'bar'), (1, 'bar'), (22, 'foo'), ]) self.assertEqual([(_.passed.total_seconds()/60, _.title) for _ in task.get_stats( start_datetime=datetime.datetime(2021, 12, 31, 8, 1, 0), stop_datetime=datetime.datetime(2021, 12, 31, 8, 30, 0), )], [ (1, 'foo'), (3, 'bar'), (1, 'bar'), (22, 'foo'), ]) self.assertEqual([(_.passed.total_seconds()/60, _.title) for _ in task.get_stats( start_datetime=datetime.datetime(2021, 12, 31, 8, 1, 0), stop_datetime=datetime.datetime(2021, 12, 31, 8, 6, 0), )], [ (1, 'foo'), (3, 'bar'), ]) self.assertEqual([(_.passed.total_seconds()/60, _.title) for _ in task.get_stats( start_datetime=datetime.datetime(2021, 12, 31, 8, 1, 0), stop_datetime=datetime.datetime(2021, 12, 31, 8, 4, 0), )], [ (1, 'foo'), (2, 'bar'), ]) self.assertEqual([(_.passed.total_seconds()/60, _.title) for _ in task.get_stats( start_datetime=datetime.datetime(2021, 12, 31, 8, 2, 0), stop_datetime=datetime.datetime(2021, 12, 31, 8, 4, 0), )], [ (2, 'bar'), ]) self.assertEqual([(_.passed.total_seconds()/60, _.title) for _ in task.get_stats( start_datetime=datetime.datetime(2021, 12, 31, 8, 3, 0), stop_datetime=datetime.datetime(2021, 12, 31, 8, 4, 0), )], [ (1, 'bar'), ]) task.stop(now=datetime.datetime(2021, 12, 31, 8, 10, 0)) self.assertEqual([(_.passed.total_seconds()/60, _.title) for _ in task.get_stats( stop_datetime=datetime.datetime(2021, 12, 31, 8, 30, 0), )], [ (2, 'foo'), (3, 'bar'), (1, 'bar'), (2, 'foo'), ])