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
c6b5ff49
Commit
c6b5ff49
authored
Oct 08, 2015
by
MinchinWeb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix PEP8 E501 (selected)
line too long (> 79 characters)
parent
059f5119
Changes
30
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
621 additions
and
313 deletions
+621
-313
test/TestAddCommand.py
test/TestAddCommand.py
+120
-60
test/TestAppendCommand.py
test/TestAppendCommand.py
+8
-4
test/TestDeleteCommand.py
test/TestDeleteCommand.py
+39
-19
test/TestDepCommand.py
test/TestDepCommand.py
+34
-17
test/TestDepriCommand.py
test/TestDepriCommand.py
+25
-12
test/TestDoCommand.py
test/TestDoCommand.py
+72
-36
test/TestEditCommand.py
test/TestEditCommand.py
+25
-12
test/TestFilter.py
test/TestFilter.py
+2
-1
test/TestGraph.py
test/TestGraph.py
+4
-2
test/TestListCommand.py
test/TestListCommand.py
+46
-23
test/TestListContextCommand.py
test/TestListContextCommand.py
+2
-1
test/TestListProjectCommand.py
test/TestListProjectCommand.py
+2
-1
test/TestPostponeCommand.py
test/TestPostponeCommand.py
+66
-33
test/TestPriorityCommand.py
test/TestPriorityCommand.py
+52
-25
test/TestRecurrence.py
test/TestRecurrence.py
+4
-2
test/TestSortCommand.py
test/TestSortCommand.py
+6
-3
test/TestSorter.py
test/TestSorter.py
+28
-14
test/TestTagCommand.py
test/TestTagCommand.py
+42
-21
test/TestTodoBase.py
test/TestTodoBase.py
+4
-2
test/TestTodoFile.py
test/TestTodoFile.py
+2
-1
test/TestTodoList.py
test/TestTodoList.py
+10
-5
topydo/cli/TopydoCompleter.py
topydo/cli/TopydoCompleter.py
+2
-1
topydo/commands/AddCommand.py
topydo/commands/AddCommand.py
+2
-1
topydo/commands/PostponeCommand.py
topydo/commands/PostponeCommand.py
+2
-2
topydo/commands/TagCommand.py
topydo/commands/TagCommand.py
+2
-2
topydo/lib/Config.py
topydo/lib/Config.py
+3
-1
topydo/lib/DCommand.py
topydo/lib/DCommand.py
+2
-1
topydo/lib/MultiCommand.py
topydo/lib/MultiCommand.py
+4
-4
topydo/lib/TodoBase.py
topydo/lib/TodoBase.py
+6
-4
topydo/lib/TodoListBase.py
topydo/lib/TodoListBase.py
+5
-3
No files found.
test/TestAddCommand.py
View file @
c6b5ff49
This diff is collapsed.
Click to expand it.
test/TestAppendCommand.py
View file @
c6b5ff49
...
...
@@ -28,14 +28,16 @@ class AppendCommandTest(CommandTest):
self
.
todolist
.
add
(
"Foo"
)
def
test_append1
(
self
):
command
=
AppendCommand
([
1
,
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
AppendCommand
([
1
,
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
"| 1| Foo Bar
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_append2
(
self
):
command
=
AppendCommand
([
2
,
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
AppendCommand
([
2
,
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
""
)
...
...
@@ -56,7 +58,8 @@ class AppendCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
test_append5
(
self
):
command
=
AppendCommand
([
1
,
"Bar"
,
"Baz"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
AppendCommand
([
1
,
"Bar"
,
"Baz"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
"| 1| Foo Bar Baz
\
n
"
)
...
...
@@ -81,7 +84,8 @@ class AppendCommandTest(CommandTest):
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
if
__name__
==
'__main__'
:
unittest
.
main
()
test/TestDeleteCommand.py
View file @
c6b5ff49
...
...
@@ -45,7 +45,8 @@ class DeleteCommandTest(CommandTest):
self
.
todolist
=
TodoList
(
todos
)
def
test_del1
(
self
):
command
=
DeleteCommand
([
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_no_prompt
)
command
=
DeleteCommand
([
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_no_prompt
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -54,7 +55,8 @@ class DeleteCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_del1_regex
(
self
):
command
=
DeleteCommand
([
"Foo"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_no_prompt
)
command
=
DeleteCommand
([
"Foo"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_no_prompt
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -63,16 +65,19 @@ class DeleteCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_del2
(
self
):
command
=
DeleteCommand
([
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_yes_prompt
)
command
=
DeleteCommand
([
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_yes_prompt
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
todolist
.
count
(),
2
)
self
.
assertEqual
(
self
.
output
,
"| 2| Bar p:1
\
n
Removed: Bar
\
n
Removed: Foo
\
n
"
)
self
.
assertEqual
(
self
.
output
,
"| 2| Bar p:1
\
n
Removed: Bar
\
n
Removed: Foo
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_del3
(
self
):
command
=
DeleteCommand
([
"-f"
,
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_yes_prompt
)
command
=
DeleteCommand
([
"-f"
,
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_yes_prompt
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -81,7 +86,8 @@ class DeleteCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_del4
(
self
):
command
=
DeleteCommand
([
"--force"
,
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_yes_prompt
)
command
=
DeleteCommand
([
"--force"
,
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_yes_prompt
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -128,7 +134,8 @@ class DeleteCommandTest(CommandTest):
def
test_multi_del1
(
self
):
""" Test deletion of multiple items. """
command
=
DeleteCommand
([
"1"
,
"2"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_no_prompt
)
command
=
DeleteCommand
([
"1"
,
"2"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_no_prompt
)
command
.
execute
()
result
=
"a @test with due:2015-06-03
\
n
a @test with +project"
...
...
@@ -138,7 +145,8 @@ class DeleteCommandTest(CommandTest):
def
test_multi_del2
(
self
):
""" Test deletion of multiple items. """
command
=
DeleteCommand
([
"1"
,
"2"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_yes_prompt
)
command
=
DeleteCommand
([
"1"
,
"2"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_yes_prompt
)
command
.
execute
()
result
=
"a @test with due:2015-06-03
\
n
a @test with +project"
...
...
@@ -148,7 +156,8 @@ class DeleteCommandTest(CommandTest):
def
test_multi_del3
(
self
):
""" Fail if any of supplied todo numbers is invalid. """
command
=
DeleteCommand
([
"99"
,
"2"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_yes_prompt
)
command
=
DeleteCommand
([
"99"
,
"2"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_yes_prompt
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -157,7 +166,8 @@ class DeleteCommandTest(CommandTest):
def
test_multi_del4
(
self
):
""" Check output when all supplied todo numbers are invalid. """
command
=
DeleteCommand
([
"99"
,
"A"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_yes_prompt
)
command
=
DeleteCommand
([
"99"
,
"A"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_yes_prompt
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -165,16 +175,21 @@ class DeleteCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given: 99.
\
n
Invalid todo number given: A.
\
n
"
)
def
test_multi_del5
(
self
):
""" Throw an error with invalid argument containing special characters. """
command
=
DeleteCommand
([
u
(
"Fo
\
u00d3
B
\
u0105
r"
),
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
"""
Throw an error with invalid argument containing special characters.
"""
command
=
DeleteCommand
([
u
(
"Fo
\
u00d3
B
\
u0105
r"
),
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
def
test_expr_del1
(
self
):
command
=
DeleteCommand
([
"-e"
,
"@test"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
DeleteCommand
([
"-e"
,
"@test"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
result
=
"Removed: a @test with due:2015-06-03
\
n
Removed: a @test with +project
\
n
"
...
...
@@ -185,7 +200,8 @@ class DeleteCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_expr_del2
(
self
):
command
=
DeleteCommand
([
"-e"
,
"@test"
,
"due:2015-06-03"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
DeleteCommand
([
"-e"
,
"@test"
,
"due:2015-06-03"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -193,14 +209,16 @@ class DeleteCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_expr_del3
(
self
):
command
=
DeleteCommand
([
"-e"
,
"@test"
,
"due:2015-06-03"
,
"+project"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
DeleteCommand
([
"-e"
,
"@test"
,
"due:2015-06-03"
,
"+project"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
def
test_expr_del4
(
self
):
""" Remove only relevant todo items. """
command
=
DeleteCommand
([
"-e"
,
""
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
DeleteCommand
([
"-e"
,
""
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
result
=
"Foo"
...
...
@@ -211,7 +229,8 @@ class DeleteCommandTest(CommandTest):
def
test_expr_del5
(
self
):
""" Force deleting unrelevant items with additional -x flag. """
command
=
DeleteCommand
([
"-xe"
,
""
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_yes_prompt
)
command
=
DeleteCommand
([
"-xe"
,
""
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_yes_prompt
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -230,7 +249,8 @@ class DeleteCommandTest(CommandTest):
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
if
__name__
==
'__main__'
:
unittest
.
main
()
test/TestDepCommand.py
View file @
c6b5ff49
...
...
@@ -36,7 +36,8 @@ class DepCommandTest(CommandTest):
self
.
todolist
=
TodoList
(
todos
)
def
test_add1
(
self
):
command
=
DepCommand
([
"add"
,
"1"
,
"to"
,
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepCommand
([
"add"
,
"1"
,
"to"
,
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -45,7 +46,8 @@ class DepCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_add2
(
self
):
command
=
DepCommand
([
"add"
,
"1"
,
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepCommand
([
"add"
,
"1"
,
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -54,7 +56,8 @@ class DepCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_add3
(
self
):
command
=
DepCommand
([
"add"
,
"99"
,
"3"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepCommand
([
"add"
,
"99"
,
"3"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -62,7 +65,8 @@ class DepCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given.
\
n
"
)
def
test_add4
(
self
):
command
=
DepCommand
([
"add"
,
"A"
,
"3"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepCommand
([
"add"
,
"A"
,
"3"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -78,7 +82,8 @@ class DepCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
test_add6
(
self
):
command
=
DepCommand
([
"add"
,
"1"
,
"after"
,
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepCommand
([
"add"
,
"1"
,
"after"
,
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -87,7 +92,8 @@ class DepCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_add7
(
self
):
command
=
DepCommand
([
"add"
,
"1"
,
"before"
,
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepCommand
([
"add"
,
"1"
,
"before"
,
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -96,7 +102,8 @@ class DepCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_add8
(
self
):
command
=
DepCommand
([
"add"
,
"1"
,
"partof"
,
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepCommand
([
"add"
,
"1"
,
"partof"
,
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -105,7 +112,8 @@ class DepCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_add9
(
self
):
command
=
DepCommand
([
"add"
,
"Foo"
,
"to"
,
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepCommand
([
"add"
,
"Foo"
,
"to"
,
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -141,7 +149,8 @@ class DepCommandTest(CommandTest):
self
.
rm_helper
([
"del"
,
"1"
,
"3"
])
def
test_rm3
(
self
):
command
=
DepCommand
([
"rm"
,
"99"
,
"3"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepCommand
([
"rm"
,
"99"
,
"3"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -149,7 +158,8 @@ class DepCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given.
\
n
"
)
def
test_rm4
(
self
):
command
=
DepCommand
([
"rm"
,
"A"
,
"3"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepCommand
([
"rm"
,
"A"
,
"3"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -165,7 +175,8 @@ class DepCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
test_ls1
(
self
):
command
=
DepCommand
([
"ls"
,
"1"
,
"to"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepCommand
([
"ls"
,
"1"
,
"to"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -173,7 +184,8 @@ class DepCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_ls2
(
self
):
command
=
DepCommand
([
"ls"
,
"99"
,
"to"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepCommand
([
"ls"
,
"99"
,
"to"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -181,7 +193,8 @@ class DepCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given.
\
n
"
)
def
test_ls3
(
self
):
command
=
DepCommand
([
"ls"
,
"to"
,
"3"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepCommand
([
"ls"
,
"to"
,
"3"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -189,7 +202,8 @@ class DepCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_ls4
(
self
):
command
=
DepCommand
([
"ls"
,
"to"
,
"99"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepCommand
([
"ls"
,
"to"
,
"99"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -213,7 +227,8 @@ class DepCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
test_ls7
(
self
):
command
=
DepCommand
([
"ls"
,
"top"
,
"99"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepCommand
([
"ls"
,
"top"
,
"99"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -221,7 +236,8 @@ class DepCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
gc_helper
(
self
,
p_subcommand
):
command
=
DepCommand
([
p_subcommand
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepCommand
([
p_subcommand
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -256,7 +272,8 @@ class DepCommandTest(CommandTest):
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
if
__name__
==
'__main__'
:
unittest
.
main
()
test/TestDepriCommand.py
View file @
c6b5ff49
...
...
@@ -64,7 +64,8 @@ class DepriCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_depri4
(
self
):
command
=
DepriCommand
([
"1"
,
"Baz"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepriCommand
([
"1"
,
"Baz"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -74,7 +75,8 @@ class DepriCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_expr_depri1
(
self
):
command
=
DepriCommand
([
"-e"
,
"@test"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
DepriCommand
([
"-e"
,
"@test"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
result
=
"Priority removed.
\
n
| 4| a @test with due:2015-06-03
\
n
Priority removed.
\
n
| 5| a @test with +project p:1
\
n
"
...
...
@@ -84,7 +86,8 @@ class DepriCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_expr_depri2
(
self
):
command
=
DepriCommand
([
"-e"
,
"@test"
,
"due:2015-06-03"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
DepriCommand
([
"-e"
,
"@test"
,
"due:2015-06-03"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
result
=
"Priority removed.
\
n
| 4| a @test with due:2015-06-03
\
n
"
...
...
@@ -94,21 +97,24 @@ class DepriCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_expr_depri3
(
self
):
command
=
DepriCommand
([
"-e"
,
"@test"
,
"due:2015-06-03"
,
"+project"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
DepriCommand
([
"-e"
,
"@test"
,
"due:2015-06-03"
,
"+project"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
def
test_expr_depri4
(
self
):
""" Don't remove priority from unrelevant todo items. """
command
=
DepriCommand
([
"-e"
,
"Bax"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
DepriCommand
([
"-e"
,
"Bax"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
def
test_expr_depri5
(
self
):
""" Force unprioritizing unrelevant items with additional -x flag. """
command
=
DepriCommand
([
"-xe"
,
"Bax"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
DepriCommand
([
"-xe"
,
"Bax"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -124,7 +130,8 @@ class DepriCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given.
\
n
"
)
def
test_invalid2
(
self
):
command
=
DepriCommand
([
"99"
,
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepriCommand
([
"99"
,
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -132,7 +139,8 @@ class DepriCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given: 99.
\
n
"
)
def
test_invalid3
(
self
):
command
=
DepriCommand
([
"99"
,
"FooBar"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepriCommand
([
"99"
,
"FooBar"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -140,13 +148,17 @@ class DepriCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given: 99.
\
n
Invalid todo number given: FooBar.
\
n
"
)
def
test_invalid4
(
self
):
""" Throw an error with invalid argument containing special characters. """
command
=
DepriCommand
([
u
(
"Fo
\
u00d3
B
\
u0105
r"
),
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
"""
Throw an error with invalid argument containing special characters.
"""
command
=
DepriCommand
([
u
(
"Fo
\
u00d3
B
\
u0105
r"
),
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
output
)
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
def
test_empty
(
self
):
command
=
DepriCommand
([],
self
.
todolist
,
self
.
out
,
self
.
error
)
...
...
@@ -161,7 +173,8 @@ class DepriCommandTest(CommandTest):
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
if
__name__
==
'__main__'
:
unittest
.
main
()
test/TestDoCommand.py
View file @
c6b5ff49
This diff is collapsed.
Click to expand it.
test/TestEditCommand.py
View file @
c6b5ff49
...
...
@@ -64,7 +64,8 @@ class EditCommandTest(CommandTest):
mock_open_in_editor
.
return_value
=
0
mock_todos_from_temp
.
return_value
=
[
Todo
(
'Lazy Cat'
)]
command
=
EditCommand
([
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
EditCommand
([
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -73,7 +74,8 @@ class EditCommandTest(CommandTest):
def
test_edit3
(
self
):
""" Throw an error after invalid todo number given as argument. """
command
=
EditCommand
([
"FooBar"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
EditCommand
([
"FooBar"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -81,7 +83,8 @@ class EditCommandTest(CommandTest):
def
test_edit4
(
self
):
""" Throw an error with pointing invalid argument. """
command
=
EditCommand
([
"Bar"
,
"5"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
EditCommand
([
"Bar"
,
"5"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -94,7 +97,8 @@ class EditCommandTest(CommandTest):
mock_open_in_editor
.
return_value
=
0
mock_todos_from_temp
.
return_value
=
[
Todo
(
'Only one line'
)]
command
=
EditCommand
([
"1"
,
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
EditCommand
([
"1"
,
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -102,12 +106,16 @@ class EditCommandTest(CommandTest):
self
.
assertEqual
(
self
.
todolist
.
print_todos
(),
u
(
"Foo id:1
\
n
Bar p:1 @test
\
n
Baz @test
\
n
Fo
\
u00f3
B
\
u0105
\
u017a
"
))
def
test_edit6
(
self
):
""" Throw an error with invalid argument containing special characters. """
command
=
EditCommand
([
u
(
"Fo
\
u00d3
B
\
u0105
r"
),
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
"""
Throw an error with invalid argument containing special characters.
"""
command
=
EditCommand
([
u
(
"Fo
\
u00d3
B
\
u0105
r"
),
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
@
mock
.
patch
(
'topydo.commands.EditCommand.EditCommand._todos_from_temp'
)
@
mock
.
patch
(
'topydo.commands.EditCommand.EditCommand._open_in_editor'
)
...
...
@@ -116,21 +124,25 @@ class EditCommandTest(CommandTest):
mock_open_in_editor
.
return_value
=
0
mock_todos_from_temp
.
return_value
=
[
Todo
(
'Lazy Cat'
)]
command
=
EditCommand
([
u
(
"Fo
\
u00f3
B
\
u0105
\
u017a
"
)],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
EditCommand
([
u
(
"Fo
\
u00f3
B
\
u0105
\
u017a
"
)],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
errors
,
""
)
self
.
assertEqual
(
self
.
todolist
.
print_todos
(),
u
(
"Foo id:1
\
n
Bar p:1 @test
\
n
Baz @test
\
n
Lazy Cat"
))
self
.
assertEqual
(
self
.
todolist
.
print_todos
(),
u
(
"Foo id:1
\
n
Bar p:1 @test
\
n
Baz @test
\
n
Lazy Cat"
))
@
mock
.
patch
(
'topydo.commands.EditCommand.EditCommand._todos_from_temp'
)
@
mock
.
patch
(
'topydo.commands.EditCommand.EditCommand._open_in_editor'
)
def
test_edit_expr
(
self
,
mock_open_in_editor
,
mock_todos_from_temp
):
""" Edit todos matching expression. """
mock_open_in_editor
.
return_value
=
0
mock_todos_from_temp
.
return_value
=
[
Todo
(
'Lazy Cat'
),
Todo
(
'Lazy Dog'
)]
mock_todos_from_temp
.
return_value
=
[
Todo
(
'Lazy Cat'
),
Todo
(
'Lazy Dog'
)]
command
=
EditCommand
([
"-e"
,
"@test"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
EditCommand
([
"-e"
,
"@test"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
expected
=
u
(
"| 3| Lazy Cat
\
n
| 4| Lazy Dog
\
n
"
)
...
...
@@ -149,7 +161,8 @@ class EditCommandTest(CommandTest):
os
.
environ
[
'EDITOR'
]
=
editor
archive
=
config
().
archive
()
command
=
EditCommand
([
"-d"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
EditCommand
([
"-d"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertEqual
(
self
.
errors
,
""
)
...
...
test/TestFilter.py
View file @
c6b5ff49
...
...
@@ -132,7 +132,8 @@ class FilterTest(TopydoTest):
filtered_todos
=
limit_filter
.
filter
(
todos
)
self
.
assertEqual
(
len
(
filtered_todos
),
1
)
self
.
assertEqual
(
filtered_todos
[
0
].
source
(),
'(C) This is part of some +Project'
)
self
.
assertEqual
(
filtered_todos
[
0
].
source
(),
'(C) This is part of some +Project'
)
def
test_filter14
(
self
):
""" Test limit filter. """
...
...
test/TestGraph.py
View file @
c6b5ff49
...
...
@@ -64,7 +64,8 @@ class GraphTest(TopydoTest):
self
.
assertEqual
(
self
.
graph
.
incoming_neighbors
(
1
,
True
),
set
())
def
test_incoming_neighbors4
(
self
):
self
.
assertEqual
(
self
.
graph
.
incoming_neighbors
(
5
,
True
),
set
([
1
,
2
,
3
,
4
,
6
]))
self
.
assertEqual
(
self
.
graph
.
incoming_neighbors
(
5
,
True
),
set
([
1
,
2
,
3
,
4
,
6
]))
def
test_outgoing_neighbors1
(
self
):
self
.
assertEqual
(
self
.
graph
.
outgoing_neighbors
(
1
),
set
([
2
,
3
]))
...
...
@@ -73,7 +74,8 @@ class GraphTest(TopydoTest):
self
.
assertEqual
(
self
.
graph
.
outgoing_neighbors
(
2
),
set
([
4
]))
def
test_outgoing_neighbors3
(
self
):
self
.
assertEqual
(
self
.
graph
.
outgoing_neighbors
(
1
,
True
),
set
([
2
,
3
,
4
,
5
,
6
]))
self
.
assertEqual
(
self
.
graph
.
outgoing_neighbors
(
1
,
True
),
set
([
2
,
3
,
4
,
5
,
6
]))
def
test_outgoing_neighbors4
(
self
):
self
.
assertEqual
(
self
.
graph
.
outgoing_neighbors
(
3
),
set
([
5
]))
...
...
test/TestListCommand.py
View file @
c6b5ff49
...
...
@@ -39,7 +39,8 @@ class ListCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_list03
(
self
):
command
=
ListCommand
([
"Context1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
([
"Context1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -47,7 +48,8 @@ class ListCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_list04
(
self
):
command
=
ListCommand
([
"-x"
,
"Context1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
([
"-x"
,
"Context1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -63,7 +65,8 @@ class ListCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_list06
(
self
):
command
=
ListCommand
([
"Project3"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
([
"Project3"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -71,7 +74,8 @@ class ListCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_list07
(
self
):
command
=
ListCommand
([
"-s"
,
"text"
,
"-x"
,
"Project1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
([
"-s"
,
"text"
,
"-x"
,
"Project1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -79,7 +83,8 @@ class ListCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_list08
(
self
):
command
=
ListCommand
([
"--"
,
"-project1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
([
"--"
,
"-project1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -87,7 +92,8 @@ class ListCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_list09
(
self
):
command
=
ListCommand
([
"--"
,
"-project1"
,
"-Drink"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
([
"--"
,
"-project1"
,
"-Drink"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -95,7 +101,8 @@ class ListCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_list10
(
self
):
command
=
ListCommand
([
"text1"
,
"2"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
([
"text1"
,
"2"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -115,7 +122,8 @@ class ListCommandTest(CommandTest):
def
test_list12
(
self
):
config
(
"test/data/listcommand.conf"
)
command
=
ListCommand
([
"-x"
,
"project"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
([
"-x"
,
"project"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -123,7 +131,8 @@ class ListCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_list13
(
self
):
command
=
ListCommand
([
"-x"
,
"--"
,
"-@Context1 +Project2"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
([
"-x"
,
"--"
,
"-@Context1 +Project2"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -159,15 +168,18 @@ class ListCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_list17
(
self
):
command
=
ListCommand
([
"-x"
,
"id:"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
([
"-x"
,
"id:"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
"| 3| (C) Baz @Context1 +Project1 key:value
\
n
"
)
self
.
assertEqual
(
self
.
output
,
"| 3| (C) Baz @Context1 +Project1 key:value
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_list18
(
self
):
command
=
ListCommand
([
"-x"
,
"date:2014-12-12"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
([
"-x"
,
"date:2014-12-12"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -177,7 +189,8 @@ class ListCommandTest(CommandTest):
""" Force showing all tags. """
config
(
'test/data/listcommand-tags.conf'
)
command
=
ListCommand
([
"-s"
,
"text"
,
"-x"
,
"Project1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
([
"-s"
,
"text"
,
"-x"
,
"Project1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -193,7 +206,8 @@ class ListCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_list21
(
self
):
command
=
ListCommand
([
"-f invalid"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
([
"-f invalid"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -216,7 +230,8 @@ class ListCommandTest(CommandTest):
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
class
ListCommandUnicodeTest
(
CommandTest
):
...
...
@@ -226,7 +241,8 @@ class ListCommandUnicodeTest(CommandTest):
def
test_list_unicode1
(
self
):
""" Unicode filters """
command
=
ListCommand
([
u
(
"
\
u25c4
"
)],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
([
u
(
"
\
u25c4
"
)],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -246,7 +262,8 @@ class ListCommandJsonTest(CommandTest):
self
.
assertFalse
(
todolist
.
is_dirty
())
jsontext
=
""
with
codecs
.
open
(
'test/data/ListCommandTest.json'
,
'r'
,
encoding
=
'utf-8'
)
as
json
:
with
codecs
.
open
(
'test/data/ListCommandTest.json'
,
'r'
,
encoding
=
'utf-8'
)
as
json
:
jsontext
=
json
.
read
()
self
.
assertEqual
(
self
.
output
,
jsontext
)
...
...
@@ -261,7 +278,8 @@ class ListCommandJsonTest(CommandTest):
self
.
assertFalse
(
todolist
.
is_dirty
())
jsontext
=
""
with
codecs
.
open
(
'test/data/ListCommandUnicodeTest.json'
,
'r'
,
encoding
=
'utf-8'
)
as
json
:
with
codecs
.
open
(
'test/data/ListCommandUnicodeTest.json'
,
'r'
,
encoding
=
'utf-8'
)
as
json
:
jsontext
=
json
.
read
()
self
.
assertEqual
(
self
.
output
,
jsontext
)
...
...
@@ -283,16 +301,19 @@ class ListCommandIcalTest(CommandTest):
def
test_ical
(
self
):
todolist
=
load_file_to_todolist
(
"test/data/ListCommandIcalTest.txt"
)
command
=
ListCommand
([
"-x"
,
"-f"
,
"ical"
],
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
([
"-x"
,
"-f"
,
"ical"
],
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
todolist
.
is_dirty
())
icaltext
=
""
with
codecs
.
open
(
'test/data/ListCommandTest.ics'
,
'r'
,
encoding
=
'utf-8'
)
as
ical
:
with
codecs
.
open
(
'test/data/ListCommandTest.ics'
,
'r'
,
encoding
=
'utf-8'
)
as
ical
:
icaltext
=
ical
.
read
()
self
.
assertEqual
(
replace_ical_tags
(
self
.
output
),
replace_ical_tags
(
icaltext
))
self
.
assertEqual
(
replace_ical_tags
(
self
.
output
),
replace_ical_tags
(
icaltext
))
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_ical_unicode
(
self
):
...
...
@@ -304,10 +325,12 @@ class ListCommandIcalTest(CommandTest):
self
.
assertTrue
(
todolist
.
is_dirty
())
icaltext
=
""
with
codecs
.
open
(
'test/data/ListCommandUnicodeTest.ics'
,
'r'
,
encoding
=
'utf-8'
)
as
ical
:
with
codecs
.
open
(
'test/data/ListCommandUnicodeTest.ics'
,
'r'
,
encoding
=
'utf-8'
)
as
ical
:
icaltext
=
ical
.
read
()
self
.
assertEqual
(
replace_ical_tags
(
self
.
output
),
replace_ical_tags
(
icaltext
))
self
.
assertEqual
(
replace_ical_tags
(
self
.
output
),
replace_ical_tags
(
icaltext
))
self
.
assertEqual
(
self
.
errors
,
""
)
if
__name__
==
'__main__'
:
...
...
test/TestListContextCommand.py
View file @
c6b5ff49
...
...
@@ -43,7 +43,8 @@ class ListContextCommandTest(CommandTest):
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
if
__name__
==
'__main__'
:
unittest
.
main
()
test/TestListProjectCommand.py
View file @
c6b5ff49
...
...
@@ -43,7 +43,8 @@ class ListProjectCommandTest(CommandTest):
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
if
__name__
==
'__main__'
:
unittest
.
main
()
test/TestPostponeCommand.py
View file @
c6b5ff49
This diff is collapsed.
Click to expand it.
test/TestPriorityCommand.py
View file @
c6b5ff49
...
...
@@ -36,15 +36,18 @@ class PriorityCommandTest(CommandTest):
self
.
todolist
=
TodoList
(
todos
)
def
test_set_prio1
(
self
):
command
=
PriorityCommand
([
"1"
,
"B"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
PriorityCommand
([
"1"
,
"B"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
"Priority changed from A to B
\
n
| 1| (B) Foo
\
n
"
)
self
.
assertEqual
(
self
.
output
,
"Priority changed from A to B
\
n
| 1| (B) Foo
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_set_prio2
(
self
):
command
=
PriorityCommand
([
"2"
,
"Z"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
PriorityCommand
([
"2"
,
"Z"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -52,15 +55,18 @@ class PriorityCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_set_prio3
(
self
):
command
=
PriorityCommand
([
"Foo"
,
"B"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
PriorityCommand
([
"Foo"
,
"B"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
"Priority changed from A to B
\
n
| 1| (B) Foo
\
n
"
)
self
.
assertEqual
(
self
.
output
,
"Priority changed from A to B
\
n
| 1| (B) Foo
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_set_prio4
(
self
):
command
=
PriorityCommand
([
"1"
,
"A"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
PriorityCommand
([
"1"
,
"A"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -68,7 +74,8 @@ class PriorityCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_set_prio5
(
self
):
command
=
PriorityCommand
([
"Foo"
,
"2"
,
"C"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
PriorityCommand
([
"Foo"
,
"2"
,
"C"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -77,7 +84,8 @@ class PriorityCommandTest(CommandTest):
def
test_set_prio6
(
self
):
""" Allow priority to be set including parentheses. """
command
=
PriorityCommand
([
"Foo"
,
"2"
,
"(C)"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
PriorityCommand
([
"Foo"
,
"2"
,
"(C)"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -85,7 +93,8 @@ class PriorityCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_expr_prio1
(
self
):
command
=
PriorityCommand
([
"-e"
,
"@test"
,
"C"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
PriorityCommand
([
"-e"
,
"@test"
,
"C"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
result
=
"Priority changed from B to C
\
n
| 3| (C) a @test with due:2015-06-03
\
n
Priority set to C.
\
n
| 4| (C) a @test with +project p:1
\
n
"
...
...
@@ -95,7 +104,8 @@ class PriorityCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_expr_prio2
(
self
):
command
=
PriorityCommand
([
"-e"
,
"@test"
,
"due:2015-06-03"
,
"C"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
PriorityCommand
([
"-e"
,
"@test"
,
"due:2015-06-03"
,
"C"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
result
=
"Priority changed from B to C
\
n
| 3| (C) a @test with due:2015-06-03
\
n
"
...
...
@@ -105,29 +115,35 @@ class PriorityCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_expr_prio3
(
self
):
command
=
PriorityCommand
([
"-e"
,
"@test"
,
"due:2015-06-03"
,
"+project"
,
"C"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
PriorityCommand
([
"-e"
,
"@test"
,
"due:2015-06-03"
,
"+project"
,
"C"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
def
test_expr_prio4
(
self
):
""" Don't prioritize unrelevant todo items. """
command
=
PriorityCommand
([
"-e"
,
"Baz"
,
"C"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
PriorityCommand
([
"-e"
,
"Baz"
,
"C"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
def
test_expr_prio5
(
self
):
""" Force prioritizing unrelevant items with additional -x flag. """
command
=
PriorityCommand
([
"-xe"
,
"Baz"
,
"D"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
PriorityCommand
([
"-xe"
,
"Baz"
,
"D"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
"Priority set to D.
\
n
| 5| (D) Baz id:1
\
n
"
)
self
.
assertEqual
(
self
.
output
,
"Priority set to D.
\
n
| 5| (D) Baz id:1
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_invalid1
(
self
):
command
=
PriorityCommand
([
"99"
,
"A"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
PriorityCommand
([
"99"
,
"A"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -135,7 +151,8 @@ class PriorityCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given.
\
n
"
)
def
test_invalid2
(
self
):
command
=
PriorityCommand
([
"1"
,
"99"
,
"A"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
PriorityCommand
([
"1"
,
"99"
,
"A"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -143,7 +160,8 @@ class PriorityCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given: 99.
\
n
"
)
def
test_invalid3
(
self
):
command
=
PriorityCommand
([
"98"
,
"99"
,
"A"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
PriorityCommand
([
"98"
,
"99"
,
"A"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -151,7 +169,8 @@ class PriorityCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given: 98.
\
n
Invalid todo number given: 99.
\
n
"
)
def
test_invalid4
(
self
):
command
=
PriorityCommand
([
"1"
,
"ZZ"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
PriorityCommand
([
"1"
,
"ZZ"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -175,20 +194,25 @@ class PriorityCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
test_invalid7
(
self
):
""" Throw an error with invalid argument containing special characters. """
command
=
PriorityCommand
([
u
(
"Fo
\
u00d3
B
\
u0105
r"
),
"Bar"
,
"C"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
"""
Throw an error with invalid argument containing special characters.
"""
command
=
PriorityCommand
([
u
(
"Fo
\
u00d3
B
\
u0105
r"
),
"Bar"
,
"C"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
def
test_invalid8
(
self
):
"""
Test that there's only one capital surrounded by non-word
characters that makes up a priority.
"""
command
=
PriorityCommand
([
"2"
,
"(Aa)"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
PriorityCommand
([
"2"
,
"(Aa)"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -200,7 +224,8 @@ class PriorityCommandTest(CommandTest):
Test that there's only one capital surrounded by non-word
characters that makes up a priority.
"""
command
=
PriorityCommand
([
"2"
,
"Aa"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
PriorityCommand
([
"2"
,
"Aa"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -216,11 +241,13 @@ class PriorityCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
test_help
(
self
):
command
=
PriorityCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
PriorityCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
if
__name__
==
'__main__'
:
unittest
.
main
()
test/TestRecurrence.py
View file @
c6b5ff49
...
...
@@ -165,12 +165,14 @@ class RecurrenceTest(TopydoTest):
def
test_no_recurrence
(
self
):
self
.
todo
.
remove_tag
(
'rec'
)
self
.
assertRaises
(
NoRecurrenceException
,
advance_recurring_todo
,
self
.
todo
)
self
.
assertRaises
(
NoRecurrenceException
,
advance_recurring_todo
,
self
.
todo
)
def
test_invalid_recurrence
(
self
):
""" Throw exception when 'rec' tag has an invalid value. """
self
.
todo
.
set_tag
(
'rec'
,
'1'
)
self
.
assertRaises
(
NoRecurrenceException
,
advance_recurring_todo
,
self
.
todo
)
self
.
assertRaises
(
NoRecurrenceException
,
advance_recurring_todo
,
self
.
todo
)
if
__name__
==
'__main__'
:
unittest
.
main
()
test/TestSortCommand.py
View file @
c6b5ff49
...
...
@@ -32,13 +32,15 @@ class SortCommandTest(CommandTest):
command
=
SortCommand
([
"text"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEqual
(
self
.
todolist
.
print_todos
(),
"First
\
n
(A) Foo
\
n
2014-06-14 Last"
)
self
.
assertEqual
(
self
.
todolist
.
print_todos
(),
"First
\
n
(A) Foo
\
n
2014-06-14 Last"
)
def
test_sort2
(
self
):
command
=
SortCommand
([],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEqual
(
self
.
todolist
.
print_todos
(),
"(A) Foo
\
n
2014-06-14 Last
\
n
First"
)
self
.
assertEqual
(
self
.
todolist
.
print_todos
(),
"(A) Foo
\
n
2014-06-14 Last
\
n
First"
)
def
test_sort3
(
self
):
""" Check that order does not influence the UID of a todo. """
...
...
@@ -56,7 +58,8 @@ class SortCommandTest(CommandTest):
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
if
__name__
==
'__main__'
:
unittest
.
main
()
test/TestSorter.py
View file @
c6b5ff49
...
...
@@ -40,21 +40,24 @@ class SorterTest(TopydoTest):
def
test_sort01
(
self
):
""" Alphabetically sorted """
sorter
=
Sorter
(
'text'
)
self
.
sort_file
(
'test/data/SorterTest1.txt'
,
'test/data/SorterTest1-result.txt'
,
sorter
)
self
.
sort_file
(
'test/data/SorterTest1.txt'
,
'test/data/SorterTest1-result.txt'
,
sorter
)
def
test_sort02a
(
self
):
"""
Ascendingly sorted by priority. Also checks stableness of the sort.
"""
sorter
=
Sorter
(
'prio'
)
self
.
sort_file
(
'test/data/SorterTest2.txt'
,
'test/data/SorterTest2-result.txt'
,
sorter
)
self
.
sort_file
(
'test/data/SorterTest2.txt'
,
'test/data/SorterTest2-result.txt'
,
sorter
)
def
test_sort02b
(
self
):
"""
Ascendingly sorted by priority. Also checks stableness of the sort.
"""
sorter
=
Sorter
(
'asc:prio'
)
self
.
sort_file
(
'test/data/SorterTest2.txt'
,
'test/data/SorterTest2-result.txt'
,
sorter
)
self
.
sort_file
(
'test/data/SorterTest2.txt'
,
'test/data/SorterTest2-result.txt'
,
sorter
)
def
test_sort03
(
self
):
"""
...
...
@@ -62,32 +65,38 @@ class SorterTest(TopydoTest):
sort.
"""
sorter
=
Sorter
(
'desc:prio'
)
self
.
sort_file
(
'test/data/SorterTest3.txt'
,
'test/data/SorterTest3-result.txt'
,
sorter
)
self
.
sort_file
(
'test/data/SorterTest3.txt'
,
'test/data/SorterTest3-result.txt'
,
sorter
)
def
test_sort04
(
self
):
""" Ascendingly sorted by due date """
sorter
=
Sorter
(
config
().
tag_due
())
self
.
sort_file
(
'test/data/SorterTest4.txt'
,
'test/data/SorterTest4-result.txt'
,
sorter
)
self
.
sort_file
(
'test/data/SorterTest4.txt'
,
'test/data/SorterTest4-result.txt'
,
sorter
)
def
test_sort05
(
self
):
""" Descendingly sorted by due date """
sorter
=
Sorter
(
'desc:due'
)
self
.
sort_file
(
'test/data/SorterTest5.txt'
,
'test/data/SorterTest5-result.txt'
,
sorter
)
self
.
sort_file
(
'test/data/SorterTest5.txt'
,
'test/data/SorterTest5-result.txt'
,
sorter
)
def
test_sort06
(
self
):
""" Ascendingly sorted by creation date """
sorter
=
Sorter
(
'creation'
)
self
.
sort_file
(
'test/data/SorterTest6.txt'
,
'test/data/SorterTest6-result.txt'
,
sorter
)
self
.
sort_file
(
'test/data/SorterTest6.txt'
,
'test/data/SorterTest6-result.txt'
,
sorter
)
def
test_sort07
(
self
):
""" Ascendingly sorted by completion date. """
sorter
=
Sorter
(
'completion'
)
self
.
sort_file
(
'test/data/SorterTest7.txt'
,
'test/data/SorterTest7-result.txt'
,
sorter
)
self
.
sort_file
(
'test/data/SorterTest7.txt'
,
'test/data/SorterTest7-result.txt'
,
sorter
)
def
test_sort08
(
self
):
""" Descendingly sorted by importance """
sorter
=
Sorter
(
'desc:importance'
)
self
.
sort_file
(
'test/data/SorterTest8.txt'
,
'test/data/SorterTest8-result.txt'
,
sorter
)
self
.
sort_file
(
'test/data/SorterTest8.txt'
,
'test/data/SorterTest8-result.txt'
,
sorter
)
def
test_sort09
(
self
):
"""
...
...
@@ -95,22 +104,26 @@ class SorterTest(TopydoTest):
ascending priority.
"""
sorter
=
Sorter
(
'desc:importance,priority'
)
self
.
sort_file
(
'test/data/SorterTest9.txt'
,
'test/data/SorterTest9-result.txt'
,
sorter
)
self
.
sort_file
(
'test/data/SorterTest9.txt'
,
'test/data/SorterTest9-result.txt'
,
sorter
)
def
test_sort10
(
self
):
""" Deal with garbage input. """
sorter
=
Sorter
(
''
)
self
.
sort_file
(
'test/data/SorterTest9.txt'
,
'test/data/SorterTest9.txt'
,
sorter
)
self
.
sort_file
(
'test/data/SorterTest9.txt'
,
'test/data/SorterTest9.txt'
,
sorter
)
def
test_sort11
(
self
):
""" Deal with garbage input. """
sorter
=
Sorter
(
'fnord'
)
self
.
sort_file
(
'test/data/SorterTest9.txt'
,
'test/data/SorterTest9.txt'
,
sorter
)
self
.
sort_file
(
'test/data/SorterTest9.txt'
,
'test/data/SorterTest9.txt'
,
sorter
)
def
test_sort12
(
self
):
""" Deal with garbage input. """
sorter
=
Sorter
(
'desc:importance,,priority'
)
self
.
sort_file
(
'test/data/SorterTest9.txt'
,
'test/data/SorterTest9-result.txt'
,
sorter
)
self
.
sort_file
(
'test/data/SorterTest9.txt'
,
'test/data/SorterTest9-result.txt'
,
sorter
)
def
test_sort13
(
self
):
"""
...
...
@@ -120,7 +133,8 @@ class SorterTest(TopydoTest):
dependencies the average importance should be equal.
"""
sorter
=
Sorter
(
'desc:importance-avg'
)
self
.
sort_file
(
'test/data/SorterTest9.txt'
,
'test/data/SorterTest9-result.txt'
,
sorter
)
self
.
sort_file
(
'test/data/SorterTest9.txt'
,
'test/data/SorterTest9-result.txt'
,
sorter
)
def
test_sort14
(
self
):
sorter
=
Sorter
(
'desc:importance-average'
)
...
...
test/TestTagCommand.py
View file @
c6b5ff49
...
...
@@ -34,7 +34,8 @@ class TagCommandTest(CommandTest):
self
.
todolist
=
TodoList
(
todos
)
def
test_add_tag1
(
self
):
command
=
TagCommand
([
"1"
,
"due"
,
"2014-10-22"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
TagCommand
([
"1"
,
"due"
,
"2014-10-22"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEqual
(
self
.
todolist
.
todo
(
1
).
source
(),
"Foo due:2014-10-22"
)
...
...
@@ -43,7 +44,8 @@ class TagCommandTest(CommandTest):
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
def
test_add_tag2
(
self
):
command
=
TagCommand
([
"Foo"
,
"due"
,
"2014-10-22"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
TagCommand
([
"Foo"
,
"due"
,
"2014-10-22"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEqual
(
self
.
todolist
.
todo
(
1
).
source
(),
"Foo due:2014-10-22"
)
...
...
@@ -52,16 +54,20 @@ class TagCommandTest(CommandTest):
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
def
test_add_tag3
(
self
):
command
=
TagCommand
([
"-a"
,
"2"
,
"due"
,
"2014-10-19"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
TagCommand
([
"-a"
,
"2"
,
"due"
,
"2014-10-19"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEqual
(
self
.
todolist
.
todo
(
2
).
source
(),
"Bar due:2014-10-22 due:2014-10-19"
)
self
.
assertEqual
(
self
.
output
,
"| 2| Bar due:2014-10-22 due:2014-10-19
\
n
"
)
self
.
assertEqual
(
self
.
todolist
.
todo
(
2
).
source
(),
"Bar due:2014-10-22 due:2014-10-19"
)
self
.
assertEqual
(
self
.
output
,
"| 2| Bar due:2014-10-22 due:2014-10-19
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
def
test_add_tag4
(
self
):
command
=
TagCommand
([
"Foox"
,
"due"
,
"2014-10-22"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
TagCommand
([
"Foox"
,
"due"
,
"2014-10-22"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -69,7 +75,8 @@ class TagCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number.
\
n
"
)
def
test_set_tag04
(
self
):
command
=
TagCommand
([
"3"
,
"due"
,
"2014-10-20"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
TagCommand
([
"3"
,
"due"
,
"2014-10-20"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -77,7 +84,8 @@ class TagCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_set_tag05
(
self
):
command
=
TagCommand
([
"4"
,
"due"
,
"2014-10-20"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"all"
)
command
=
TagCommand
([
"4"
,
"due"
,
"2014-10-20"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"all"
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -85,7 +93,8 @@ class TagCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_set_tag06
(
self
):
command
=
TagCommand
([
"4"
,
"due"
,
"2014-10-20"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"1"
)
command
=
TagCommand
([
"4"
,
"due"
,
"2014-10-20"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"1"
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -93,7 +102,8 @@ class TagCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_set_tag07
(
self
):
command
=
TagCommand
([
"4"
,
"due"
,
"2014-10-20"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"2"
)
command
=
TagCommand
([
"4"
,
"due"
,
"2014-10-20"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"2"
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -101,7 +111,8 @@ class TagCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_set_tag08
(
self
):
command
=
TagCommand
([
"4"
,
"due"
,
"2014-10-20"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
""
)
command
=
TagCommand
([
"4"
,
"due"
,
"2014-10-20"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
""
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -109,7 +120,8 @@ class TagCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_set_tag09
(
self
):
command
=
TagCommand
([
"4"
,
"due"
,
"2014-10-20"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"99"
)
command
=
TagCommand
([
"4"
,
"due"
,
"2014-10-20"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"99"
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -117,11 +129,13 @@ class TagCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_set_tag10
(
self
):
command
=
TagCommand
([
"-f"
,
"4"
,
"due"
,
"2014-10-20"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"99"
)
command
=
TagCommand
([
"-f"
,
"4"
,
"due"
,
"2014-10-20"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"99"
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
"| 4| Fnord due:2014-10-20 due:2014-10-20
\
n
"
)
self
.
assertEqual
(
self
.
output
,
"| 4| Fnord due:2014-10-20 due:2014-10-20
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_rm_tag01
(
self
):
...
...
@@ -141,15 +155,18 @@ class TagCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_rm_tag03
(
self
):
command
=
TagCommand
([
"4"
,
"due"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"all"
)
command
=
TagCommand
([
"4"
,
"due"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"all"
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
" 1. 2014-10-20
\
n
2. 2014-10-22
\
n
| 4| Fnord
\
n
"
)
self
.
assertEqual
(
self
.
output
,
" 1. 2014-10-20
\
n
2. 2014-10-22
\
n
| 4| Fnord
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_rm_tag04
(
self
):
command
=
TagCommand
([
"4"
,
"due"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"1"
)
command
=
TagCommand
([
"4"
,
"due"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"1"
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -157,7 +174,8 @@ class TagCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_rm_tag06
(
self
):
command
=
TagCommand
([
"4"
,
"due"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"99"
)
command
=
TagCommand
([
"4"
,
"due"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"99"
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -165,7 +183,8 @@ class TagCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_rm_tag07
(
self
):
command
=
TagCommand
([
"4"
,
"due"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"A"
)
command
=
TagCommand
([
"4"
,
"due"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"A"
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
...
...
@@ -189,7 +208,8 @@ class TagCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number.
\
n
"
)
def
test_rm_tag10
(
self
):
command
=
TagCommand
([
"-f"
,
"4"
,
"due"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"A"
)
command
=
TagCommand
([
"-f"
,
"4"
,
"due"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
t
:
"A"
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
...
...
@@ -209,7 +229,8 @@ class TagCommandTest(CommandTest):
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
if
__name__
==
'__main__'
:
unittest
.
main
()
test/TestTodoBase.py
View file @
c6b5ff49
...
...
@@ -98,7 +98,8 @@ class TodoBaseTester(TopydoTest):
todo
.
set_tag
(
'foo'
,
'blah'
)
self
.
assertTrue
(
todo
.
has_tag
(
'foo'
,
'blah'
))
self
.
assertTrue
(
todo
.
has_tag
(
'foo'
,
'bar'
)
or
todo
.
has_tag
(
'foo'
,
'baz'
))
self
.
assertTrue
(
todo
.
has_tag
(
'foo'
,
'bar'
)
or
todo
.
has_tag
(
'foo'
,
'baz'
))
def
test_set_tag_empty_value
(
self
):
todo
=
TodoBase
(
"(C) Foo foo:bar foo:baz"
)
...
...
@@ -281,7 +282,8 @@ class TodoBaseTester(TopydoTest):
today_str
=
today
.
isoformat
()
self
.
assertEqual
(
todo
.
fields
[
'completionDate'
],
today
)
self
.
assertTrue
(
re
.
match
(
'^x '
+
today_str
+
' 2014-06-12 Foo'
,
todo
.
src
))
self
.
assertTrue
(
re
.
match
(
'^x '
+
today_str
+
' 2014-06-12 Foo'
,
todo
.
src
))
def
test_set_complete5
(
self
):
todo
=
TodoBase
(
"x 2014-06-13 Foo"
)
...
...
test/TestTodoFile.py
View file @
c6b5ff49
...
...
@@ -30,7 +30,8 @@ class TodoFileTest(TopydoTest):
def
test_utf_8
(
self
):
todofile
=
load_file
(
'test/data/utf-8.txt'
)
self
.
assertEqual
(
todofile
[
0
].
source
(),
u
(
'(C)
\
u25ba
UTF-8 test
\
u25c4
'
))
self
.
assertEqual
(
todofile
[
0
].
source
(),
u
(
'(C)
\
u25ba
UTF-8 test
\
u25c4
'
))
if
__name__
==
'__main__'
:
unittest
.
main
()
test/TestTodoList.py
View file @
c6b5ff49
...
...
@@ -71,7 +71,8 @@ class TodoListTester(TopydoTest):
self.todolist.add('
\
n
(
C
)
New
task
')
self.assertEqual(self.todolist.count(), count + 1)
self.assertEqual(self.todolist.todo(count + 1).source(), '
(
C
)
New
task
')
self.assertEqual(self.todolist.todo(count + 1).source(),
'
(
C
)
New
task
')
self.assertEqual(self.todolist.todo(count + 1).priority(), '
C
')
def test_add3b(self):
...
...
@@ -79,7 +80,8 @@ class TodoListTester(TopydoTest):
self.todolist.add('
(
C
)
New
task
\
n
')
self.assertEqual(self.todolist.count(), count + 1)
self.assertEqual(self.todolist.todo(count + 1).source(), '
(
C
)
New
task
')
self.assertEqual(self.todolist.todo(count + 1).source(),
'
(
C
)
New
task
')
self.assertEqual(self.todolist.todo(count + 1).priority(), '
C
')
def test_add4(self):
...
...
@@ -142,7 +144,8 @@ class TodoListTester(TopydoTest):
def test_todo(self):
count = self.todolist.count()
self.assertRaises(InvalidTodoException, self.todolist.todo, count + 100)
self.assertRaises(InvalidTodoException, self.todolist.todo,
count + 100)
self.assertFalse(self.todolist.is_dirty())
def test_count(self):
...
...
@@ -198,7 +201,8 @@ class TodoListTester(TopydoTest):
def test_uid1(self):
config("test/data/todolist-uid.conf")
self.assertEqual(self.todolist.todo('
t5c
').source(), "(C) Foo @Context2 Not@Context +Project1 Not+Project")
self.assertEqual(self.todolist.todo('
t5c
').source(),
"(C) Foo @Context2 Not@Context +Project1 Not+Project")
def test_uid2(self):
""" Changing the priority should not change the identifier. """
...
...
@@ -206,7 +210,8 @@ class TodoListTester(TopydoTest):
todo = self.todolist.todo('
t5c
')
self.todolist.set_priority(todo, 'B')
self.assertEqual(self.todolist.todo('
t5c
').source(), "(B) Foo @Context2 Not@Context +Project1 Not+Project")
self.assertEqual(self.todolist.todo('
t5c
').source(),
"(B) Foo @Context2 Not@Context +Project1 Not+Project")
def test_uid3(self):
"""
...
...
topydo/cli/TopydoCompleter.py
View file @
c6b5ff49
...
...
@@ -109,7 +109,8 @@ class TopydoCompleter(Completer):
def
get_completions
(
self
,
p_document
,
_
):
# include all characters except whitespaces (for + and @)
word_before_cursor
=
p_document
.
get_word_before_cursor
(
True
)
is_first_word
=
not
re
.
match
(
r'\
s*
\S+\
s
', p_document.current_line_before_cursor)
is_first_word
=
not
re
.
match
(
r'\
s*
\S+\
s
',
p_document.current_line_before_cursor)
if is_first_word:
return _subcommands(word_before_cursor)
...
...
topydo/commands/AddCommand.py
View file @
c6b5ff49
...
...
@@ -65,7 +65,8 @@ class AddCommand(Command):
It detects a priority mid-sentence and puts it at the start.
"""
todo_text
=
re
.
sub
(
r'^(.+) (\
([A-Z]
\))(.*)$'
,
r'\2 \1\3'
,
p_todo_text
)
todo_text
=
re
.
sub
(
r'^(.+) (\
([A-Z]
\))(.*)$'
,
r'\2 \1\3'
,
p_todo_text
)
return
todo_text
...
...
topydo/commands/PostponeCommand.py
View file @
c6b5ff49
...
...
@@ -85,8 +85,8 @@ Synopsis: postpone [-s] <NUMBER> [<NUMBER2> ...] <PATTERN>"
return
"""
\
Postpone the todo item(s) with the given number(s) and the given pattern.
Postponing is done by adjusting the due date(s) of the todo(s), and if the -s
flag is
given, the start date accordingly.
Postponing is done by adjusting the due date(s) of the todo(s), and if the -s
flag is
given, the start date accordingly.
It is also possible to postpone items as complete with an expression using
the -e flag. Use -x to also process todo items that are normally invisible
...
...
topydo/commands/TagCommand.py
View file @
c6b5ff49
...
...
@@ -131,6 +131,6 @@ is omitted, the tag is removed from the todo item.
-a : Do not change the current value of the tag if it exists, but add a new
value.
-f : Force setting/removing all values of the tag. Prevents interaction with
the
user.
-f : Force setting/removing all values of the tag. Prevents interaction with
the
user.
"""
topydo/lib/Config.py
View file @
c6b5ff49
...
...
@@ -203,7 +203,9 @@ class _Config:
hidden_tags
.
split
(
','
)]
def
priority_colors
(
self
):
""" Returns a dict with priorities as keys and color numbers as value. """
"""
Returns a dict with priorities as keys and color numbers as value.
"""
pri_colors_str
=
self
.
cp
.
get
(
'colorscheme'
,
'priority_colors'
)
def
_str_to_dict
(
p_string
):
...
...
topydo/lib/DCommand.py
View file @
c6b5ff49
...
...
@@ -36,7 +36,8 @@ class DCommand(MultiCommand):
self
.
force
=
False
self
.
length
=
len
(
self
.
todolist
.
todos
())
# to determine newly activated todos
# to determine newly activated todos
self
.
length
=
len
(
self
.
todolist
.
todos
())
def
get_flags
(
self
):
return
(
"f"
,
[
"force"
])
...
...
topydo/lib/MultiCommand.py
View file @
c6b5ff49
...
...
@@ -80,11 +80,11 @@ class MultiCommand(ExpressionCommand):
def
_catch_todo_errors
(
self
):
"""
Returns None or list of error messages depending on number of valid
todo
objects and number of invalid todo IDs.
Returns None or list of error messages depending on number of valid
todo
objects and number of invalid todo IDs.
In case of multiple invalid todo IDs we generate separate error message
for each
one of them with information about supplied ID.
In case of multiple invalid todo IDs we generate separate error message
for each
one of them with information about supplied ID.
"""
errors
=
[]
...
...
topydo/lib/TodoBase.py
View file @
c6b5ff49
...
...
@@ -124,7 +124,8 @@ class TodoBase(object):
# Build a new list that excludes the specified tag, match by value when
# p_value is given.
self
.
fields
[
'tags'
]
=
[
t
for
t
in
self
.
fields
[
'tags'
]
\
if
not
(
t
[
0
]
==
p_key
and
(
p_value
==
""
or
t
[
1
]
==
p_value
))]
if
not
(
t
[
0
]
==
p_key
and
(
p_value
==
""
or
t
[
1
]
==
p_value
))]
# when value == "", match any value having key p_key
value
=
p_value
if
p_value
!=
""
else
r'\
S+
'
...
...
@@ -206,7 +207,8 @@ class TodoBase(object):
self.fields['
completionDate
'] = p_completion_date
self.src = re.sub(r'
^
(
\
([
A
-
Z
]
\
)
)
?
',
\
'
x
' + p_completion_date.isoformat() + '
', self.src)
'
x
' + p_completion_date.isoformat() + '
',
self.src)
def set_creation_date(self, p_date=date.today()):
"""
...
...
@@ -220,8 +222,8 @@ class TodoBase(object):
self.src = re.sub(
r'
^
(
x
\
d
{
4
}
-
\
d
{
2
}
-
\
d
{
2
}
|
\
([
A
-
Z
]
\
)
)
?
(
\
d
{
4
}
-
\
d
{
2
}
-
\
d
{
2
}
)
?
(.
*
)
$
',
lambda m:
\
u("{}{} {}").format(m.group(1) or '', p_date.isoformat(),
m.group(3)),
self.src)
u("{}{} {}").format(m.group(1) or '', p_date.isoformat(),
m.group(3)),
self.src)
def creation_date(self):
""" Returns the creation date of a todo. """
...
...
topydo/lib/TodoListBase.py
View file @
c6b5ff49
...
...
@@ -133,7 +133,9 @@ class TodoListBase(object):
return result
def add(self, p_src):
""" Given a todo string, parse it and put it to the end of the list. """
"""
Given a todo string, parse it and put it to the end of the list.
"""
todos = self.add_list([p_src])
return todos[0] if len(todos) else None
...
...
@@ -248,8 +250,8 @@ class TodoListBase(object):
def
_update_todo_ids
(
self
):
# the idea is to have a hash that is independent of the position of the
# todo. Use the text (without tags) of the todo to keep the id as
stable
# as possible (not influenced by priorities or due dates, etc.)
# todo. Use the text (without tags) of the todo to keep the id as
#
stable
as possible (not influenced by priorities or due dates, etc.)
self
.
_todo_id_map
=
{}
self
.
_id_todo_map
=
{}
...
...
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