Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
7a32e218
Commit
7a32e218
authored
Apr 29, 2016
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test cases and assume 14 days when due < start or creation date
parent
561ba74f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
13 deletions
+31
-13
test/test_progress_color.py
test/test_progress_color.py
+13
-6
topydo/lib/ProgressColor.py
topydo/lib/ProgressColor.py
+18
-7
No files found.
test/test_progress_color.py
View file @
7a32e218
...
...
@@ -125,35 +125,35 @@ class ProgressColorTest(TopydoTest):
def
test_progress17
(
self
):
""" Due tomorrow (creation date + recurrence + start date) """
color
=
progress_color
(
Todo
(
'2016-12-01 Foo due:2016-01-02 rec:1d t:2016-01-02'
))
self
.
assertEqual
(
color
.
color
,
3
)
self
.
assertEqual
(
color
.
color
,
2
)
def
test_progress18
(
self
):
""" Due tomorrow (creation date + recurrence + start date) """
set_256_colors
()
color
=
progress_color
(
Todo
(
'2015-12-01 Foo due:2016-01-02 rec:1d t:2016-01-02'
))
self
.
assertEqual
(
color
.
color
,
2
08
)
self
.
assertEqual
(
color
.
color
,
2
2
)
def
test_progress19
(
self
):
""" Due tomorrow (creation date + strict recurrence + start date) """
color
=
progress_color
(
Todo
(
'2016-12-01 Foo due:2016-01-02 rec:+1d t:2016-01-02'
))
self
.
assertEqual
(
color
.
color
,
3
)
self
.
assertEqual
(
color
.
color
,
2
)
def
test_progress20
(
self
):
""" Due tomorrow (creation date + strict recurrence + start date) """
set_256_colors
()
color
=
progress_color
(
Todo
(
'2015-12-01 Foo due:2016-01-02 rec:+1d t:2016-01-02'
))
self
.
assertEqual
(
color
.
color
,
2
08
)
self
.
assertEqual
(
color
.
color
,
2
2
)
def
test_progress21
(
self
):
""" Due tomorrow (creation date + start date) """
color
=
progress_color
(
Todo
(
'2016-12-01 Foo due:2016-01-02 t:2016-01-02'
))
self
.
assertEqual
(
color
.
color
,
3
)
self
.
assertEqual
(
color
.
color
,
2
)
def
test_progress22
(
self
):
""" Due tomorrow (creation date + start date) """
set_256_colors
()
color
=
progress_color
(
Todo
(
'2015-12-01 Foo due:2016-01-02 t:2016-01-02'
))
self
.
assertEqual
(
color
.
color
,
2
08
)
self
.
assertEqual
(
color
.
color
,
2
2
)
def
test_progress23
(
self
):
""" Due tomorrow (creation date + start date) """
...
...
@@ -179,5 +179,12 @@ class ProgressColorTest(TopydoTest):
# a length of 14 days is assumed
self
.
assertEqual
(
color
.
color
,
208
)
def
test_progress27
(
self
):
""" Creation date after due date """
set_256_colors
()
color
=
progress_color
(
Todo
(
'2016-01-03 Foo due:2016-01-02'
))
# a length of 14 days is assumed
self
.
assertEqual
(
color
.
color
,
208
)
if
__name__
==
'__main__'
:
unittest
.
main
()
topydo/lib/ProgressColor.py
View file @
7a32e218
...
...
@@ -20,6 +20,11 @@ from topydo.lib.Color import Color
from
topydo.lib.Config
import
config
from
topydo.lib.Recurrence
import
relative_date_to_date
# when a todo item has not enough information to determine the length, assume
# this length
ASSUMED_TODO_LENGTH
=
14
# days
def
progress_color
(
p_todo
):
color16_range
=
[
2
,
# green
...
...
@@ -48,18 +53,24 @@ def progress_color(p_todo):
diff
=
p_end
-
p_start
return
diff
.
days
if
p_todo
.
has_tag
(
'rec'
)
and
p_todo
.
due_date
()
\
and
not
p_todo
.
start_date
():
does_recur
=
p_todo
.
has_tag
(
'rec'
)
start_date
=
p_todo
.
start_date
()
due_date
=
p_todo
.
due_date
()
creation_date
=
p_todo
.
creation_date
()
if
does_recur
and
due_date
and
not
start_date
:
# add negation, offset is based on due date
recurrence_pattern
=
p_todo
.
tag_value
(
'rec'
)
neg_recurrence_pattern
=
re
.
sub
(
'^
\
+?
'
, '
-
', recurrence_pattern)
start = relative_date_to_date(
neg_recurrence_pattern, p_todo.due_date())
due = p_todo.due_date()
result = diff_days(start, due)
start = relative_date_to_date(neg_recurrence_pattern, due_date)
result = diff_days(start, due_date)
elif due_date and not start_date and not creation_date:
result = ASSUMED_TODO_LENGTH
elif due_date and start_date and due_date < start_date:
result = ASSUMED_TODO_LENGTH
elif due_date and not start_date and creation_date and due_date < creation_date:
result = ASSUMED_TODO_LENGTH
else:
result = p_todo.length()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment