From 570f677ab9b144664287ffe71006db92d72f4d6e Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sun, 10 Oct 2021 10:27:53 -0400 Subject: [PATCH 1/3] task: Do not rely on raw value of waiting status This makes waiting compatible with 2.6.0 and newer. --- tasklib/task.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tasklib/task.py b/tasklib/task.py index c4a37a7..eed590c 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -1,12 +1,13 @@ from __future__ import print_function import copy +import datetime import importlib import json import logging import os import sys -from .serializing import SerializingObject +from .serializing import SerializingObject, local_zone DATE_FORMAT = '%Y%m%dT%H%M%SZ' REPR_OUTPUT_SIZE = 10 @@ -295,7 +296,10 @@ def deleted(self): @property def waiting(self): - return self['status'] == 'waiting' + if not self['wait']: + return False + + return self['wait'] > local_zone.localize(datetime.datetime.now()) @property def pending(self): @@ -523,7 +527,7 @@ def deleted(self): return self.filter(status=DELETED) def waiting(self): - return self.filter(status=WAITING) + return self.filter(wait__after='now') def recurring(self): return self.filter(status=RECURRING) From c74b958c1e6a4b3dd1c5b98b67e7315d2b6752a0 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sun, 10 Oct 2021 10:28:24 -0400 Subject: [PATCH 2/3] tests: Add test for the waiting property --- tasklib/tests.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tasklib/tests.py b/tasklib/tests.py index 39f146c..569134e 100644 --- a/tasklib/tests.py +++ b/tasklib/tests.py @@ -131,6 +131,16 @@ def test_waiting_non_empty(self): self.assertEqual(len(self.tw.tasks.waiting()), 1) + def test_waiting_property(self): + t = Task(self.tw, description='test task') + t.save() + self.assertFalse(t.waiting) + + t['wait'] = datetime.datetime.now() + datetime.timedelta(days=1) + t.save() + + self.assertTrue(t.waiting) + def test_recurring_empty(self): Task(self.tw, description='test task').save() self.assertEqual(len(self.tw.tasks.recurring()), 0) From a58088ff138a96e0c8f9c8f0d61d82814c434ae1 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sun, 10 Oct 2021 10:31:14 -0400 Subject: [PATCH 3/3] Bump version to 2.4.3 --- docs/conf.py | 4 ++-- setup.py | 2 +- tasklib/__init__.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index a6cacb8..d36eb56 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -51,9 +51,9 @@ # built documents. # # The short X.Y version. -version = '2.4.2' +version = '2.4.3' # The full version, including alpha/beta/rc tags. -release = '2.4.2' +release = '2.4.3' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.py b/setup.py index 035bb43..7dd9d2a 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ install_requirements = ['pytz', 'tzlocal'] -version = '2.4.2' +version = '2.4.3' try: import importlib diff --git a/tasklib/__init__.py b/tasklib/__init__.py index 4172240..b28e8c4 100644 --- a/tasklib/__init__.py +++ b/tasklib/__init__.py @@ -2,4 +2,4 @@ from .task import Task from .serializing import local_zone -__version__ = '2.4.2' +__version__ = '2.4.3'