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
93c956f3
Commit
93c956f3
authored
Oct 22, 2016
by
William (B.J.) Snow Orvis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix importance being wrong when due date is a distant monday.
parent
515cfe23
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
2 deletions
+38
-2
test/test_importance.py
test/test_importance.py
+34
-0
topydo/lib/Importance.py
topydo/lib/Importance.py
+4
-2
No files found.
test/test_importance.py
View file @
93c956f3
...
@@ -56,5 +56,39 @@ class ImportanceTest(TopydoTest):
...
@@ -56,5 +56,39 @@ class ImportanceTest(TopydoTest):
todo
=
Todo
(
"(C) Foo "
+
config
().
tag_due
()
+
":"
+
"2015-11-09"
)
todo
=
Todo
(
"(C) Foo "
+
config
().
tag_due
()
+
":"
+
"2015-11-09"
)
self
.
assertEqual
(
importance
(
todo
),
6
)
self
.
assertEqual
(
importance
(
todo
),
6
)
@
freeze_time
(
"2016, 10, 21"
)
class
ImportanceWeekendFridayTest
(
TopydoTest
):
def
test_importance_ignore_weekends_due_not_next_monday
(
self
):
# Today is friday
# due on a monday, but over a month away.
# So 2 + 0 (no priority) + 0 (no star) + 0 (due > 14 days)
config
(
p_overrides
=
{(
'sort'
,
'ignore_weekends'
):
'1'
})
todo
=
Todo
(
"Foo "
+
config
().
tag_due
()
+
":"
+
"2016-11-28"
)
self
.
assertEqual
(
importance
(
todo
),
2
)
@
freeze_time
(
"2016, 10, 22"
)
class
ImportanceWeekendSaturdayTest
(
TopydoTest
):
def
test_importance_ignore_weekends_due_not_next_monday
(
self
):
# Today is saturday
# due on a monday, but over a month away.
# So 2 + 0 (no priority) + 0 (no star) + 0 (due > 14 days)
config
(
p_overrides
=
{(
'sort'
,
'ignore_weekends'
):
'1'
})
todo
=
Todo
(
"Foo "
+
config
().
tag_due
()
+
":"
+
"2016-11-28"
)
self
.
assertEqual
(
importance
(
todo
),
2
)
@
freeze_time
(
"2016, 10, 23"
)
class
ImportanceWeekendSundayTest
(
TopydoTest
):
def
test_importance_ignore_weekends_due_not_next_monday
(
self
):
# Today is sunday
# due on a monday, but over a month away.
# So 2 + 0 (no priority) + 0 (no star) + 0 (due > 14 days)
config
(
p_overrides
=
{(
'sort'
,
'ignore_weekends'
):
'1'
})
todo
=
Todo
(
"Foo "
+
config
().
tag_due
()
+
":"
+
"2016-11-28"
)
self
.
assertEqual
(
importance
(
todo
),
2
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
topydo/lib/Importance.py
View file @
93c956f3
...
@@ -31,12 +31,14 @@ IMPORTANCE_VALUE = {'A': 3, 'B': 2, 'C': 1}
...
@@ -31,12 +31,14 @@ IMPORTANCE_VALUE = {'A': 3, 'B': 2, 'C': 1}
def
is_due_next_monday
(
p_todo
):
def
is_due_next_monday
(
p_todo
):
""" Returns True when the given task is due next Monday. """
""" Returns True when today is Friday (or the weekend) and the given task
is due next Monday.
"""
today
=
date
.
today
()
today
=
date
.
today
()
due
=
p_todo
.
due_date
()
due
=
p_todo
.
due_date
()
return
due
and
due
.
weekday
()
==
0
and
today
.
weekday
()
>=
4
and
\
return
due
and
due
.
weekday
()
==
0
and
today
.
weekday
()
>=
4
and
\
p_todo
.
days_till_due
()
p_todo
.
days_till_due
()
<=
3
def
importance
(
p_todo
,
p_ignore_weekend
=
config
().
ignore_weekends
()):
def
importance
(
p_todo
,
p_ignore_weekend
=
config
().
ignore_weekends
()):
...
...
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