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
4d049970
Commit
4d049970
authored
Jun 08, 2015
by
Jacek Sowiński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test expressions in del, depri, do, postpone, pri
parent
0d2cedd8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
254 additions
and
15 deletions
+254
-15
test/DeleteCommandTest.py
test/DeleteCommandTest.py
+60
-6
test/DepriCommandTest.py
test/DepriCommandTest.py
+47
-0
test/DoCommandTest.py
test/DoCommandTest.py
+51
-9
test/PostponeCommandTest.py
test/PostponeCommandTest.py
+50
-0
test/PriorityCommandTest.py
test/PriorityCommandTest.py
+46
-0
No files found.
test/DeleteCommandTest.py
View file @
4d049970
...
...
@@ -35,6 +35,8 @@ class DeleteCommandTest(CommandTest):
todos
=
[
"Foo id:1"
,
"Bar p:1"
,
"a @test with due:2015-06-03"
,
"a @test with +project"
,
]
self
.
todolist
=
TodoList
(
todos
)
...
...
@@ -62,7 +64,7 @@ class DeleteCommandTest(CommandTest):
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
todolist
.
count
(),
0
)
self
.
assertEqual
(
self
.
todolist
.
count
(),
2
)
self
.
assertEqual
(
self
.
output
,
"| 2| Bar p:1
\
n
Removed: Bar
\
n
Removed: Foo
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
...
...
@@ -71,7 +73,7 @@ class DeleteCommandTest(CommandTest):
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
todolist
.
count
(),
1
)
# force won't delete subtasks
self
.
assertEqual
(
self
.
todolist
.
count
(),
3
)
# force won't delete subtasks
self
.
assertEqual
(
self
.
output
,
"| 2| Bar p:1
\
n
Removed: Foo id:1
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
...
...
@@ -80,7 +82,7 @@ class DeleteCommandTest(CommandTest):
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
todolist
.
count
(),
1
)
# force won't delete subtasks
self
.
assertEqual
(
self
.
todolist
.
count
(),
3
)
# force won't delete subtasks
self
.
assertEqual
(
self
.
output
,
"| 2| Bar p:1
\
n
Removed: Foo id:1
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
...
...
@@ -116,7 +118,9 @@ class DeleteCommandTest(CommandTest):
command
=
DeleteCommand
([
"8to"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEqual
(
self
.
todolist
.
print_todos
(),
"Foo"
)
result
=
"Foo
\
n
a @test with due:2015-06-03
\
n
a @test with +project"
self
.
assertEqual
(
self
.
todolist
.
print_todos
(),
result
)
self
.
assertRaises
(
InvalidTodoException
,
self
.
todolist
.
todo
,
'b0n'
)
def
test_multi_del1
(
self
):
...
...
@@ -124,14 +128,20 @@ class DeleteCommandTest(CommandTest):
command
=
DeleteCommand
([
"1"
,
"2"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_no_prompt
)
command
.
execute
()
self
.
assertEqual
(
self
.
todolist
.
count
(),
0
)
result
=
"a @test with due:2015-06-03
\
n
a @test with +project"
self
.
assertEqual
(
self
.
todolist
.
count
(),
2
)
self
.
assertEqual
(
self
.
todolist
.
print_todos
(),
result
)
def
test_multi_del2
(
self
):
""" Test deletion of multiple items. """
command
=
DeleteCommand
([
"1"
,
"2"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_yes_prompt
)
command
.
execute
()
self
.
assertEqual
(
self
.
todolist
.
count
(),
0
)
result
=
"a @test with due:2015-06-03
\
n
a @test with +project"
self
.
assertEqual
(
self
.
todolist
.
count
(),
2
)
self
.
assertEqual
(
self
.
todolist
.
print_todos
(),
result
)
def
test_multi_del3
(
self
):
""" Fail if any of supplied todo numbers is invalid. """
...
...
@@ -160,6 +170,50 @@ class DeleteCommandTest(CommandTest):
self
.
assertEqual
(
self
.
output
,
""
)
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
.
execute
()
result
=
"Removed: a @test with due:2015-06-03
\
n
Removed: a @test with +project
\
n
"
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
todolist
.
count
(),
2
)
self
.
assertEqual
(
self
.
output
,
result
)
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
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
"Removed: a @test with due:2015-06-03
\
n
"
)
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
.
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
.
execute
()
result
=
"Foo"
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
todolist
.
count
(),
1
)
self
.
assertEqual
(
self
.
todolist
.
print_todos
(),
result
)
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
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
todolist
.
count
(),
0
)
def
test_empty
(
self
):
command
=
DeleteCommand
([],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
test/DepriCommandTest.py
View file @
4d049970
...
...
@@ -28,6 +28,9 @@ class DepriCommandTest(CommandTest):
"(A) Foo"
,
"Bar"
,
"(B) Baz"
,
"(E) a @test with due:2015-06-03"
,
"(Z) a @test with +project p:1"
,
"(D) Bax id:1"
,
]
self
.
todolist
=
TodoList
(
todos
)
...
...
@@ -69,6 +72,50 @@ class DepriCommandTest(CommandTest):
self
.
assertEqual
(
self
.
output
,
"Priority removed.
\
n
| 1| Foo
\
n
Priority removed.
\
n
| 3| Baz
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_expr_depri1
(
self
):
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
"
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
result
)
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
.
execute
()
result
=
"Priority removed.
\
n
| 4| a @test with due:2015-06-03
\
n
"
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
result
)
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
.
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
.
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
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
"Priority removed.
\
n
| 6| Bax id:1
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_invalid1
(
self
):
command
=
DepriCommand
([
"99"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
...
...
test/DoCommandTest.py
View file @
4d049970
...
...
@@ -41,6 +41,8 @@ class DoCommandTest(CommandTest):
"Subtodo of inactive p:2"
,
"Strict due:2014-01-01 rec:1d"
,
"Invalid rec:1"
,
"a @test with due:2015-06-03"
,
"a @test with +project"
,
]
self
.
todolist
=
TodoList
(
todos
)
...
...
@@ -123,7 +125,7 @@ class DoCommandTest(CommandTest):
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
errors
,
""
)
self
.
assertEqual
(
self
.
todolist
.
count
(),
1
0
)
self
.
assertEqual
(
self
.
todolist
.
count
(),
1
2
)
def
test_recurrence
(
self
):
self
.
assertFalse
(
self
.
todolist
.
todo
(
4
).
has_tag
(
'due'
))
...
...
@@ -131,7 +133,7 @@ class DoCommandTest(CommandTest):
self
.
_recurrence_helper
([
"4"
])
self
.
assertTrue
(
self
.
todolist
.
todo
(
4
).
is_completed
())
result
=
"| 1
0
| {today} Recurring! rec:1d due:{tomorrow}
\
n
Completed: x {today} Recurring! rec:1d
\
n
"
.
format
(
today
=
self
.
today
,
tomorrow
=
self
.
tomorrow
)
result
=
"| 1
2
| {today} Recurring! rec:1d due:{tomorrow}
\
n
Completed: x {today} Recurring! rec:1d
\
n
"
.
format
(
today
=
self
.
today
,
tomorrow
=
self
.
tomorrow
)
self
.
assertEqual
(
self
.
output
,
result
)
todo
=
self
.
todolist
.
todo
(
10
)
...
...
@@ -140,13 +142,13 @@ class DoCommandTest(CommandTest):
def
test_strict_recurrence1
(
self
):
self
.
_recurrence_helper
([
"-s"
,
"8"
])
result
=
"| 1
0
| {today} Strict due:2014-01-02 rec:1d
\
n
Completed: x {today} Strict due:2014-01-01 rec:1d
\
n
"
.
format
(
today
=
self
.
today
)
result
=
"| 1
2
| {today} Strict due:2014-01-02 rec:1d
\
n
Completed: x {today} Strict due:2014-01-01 rec:1d
\
n
"
.
format
(
today
=
self
.
today
)
self
.
assertEqual
(
self
.
output
,
result
)
def
test_strict_recurrence2
(
self
):
self
.
_recurrence_helper
([
"--strict"
,
"8"
])
result
=
"| 1
0
| {today} Strict due:2014-01-02 rec:1d
\
n
Completed: x {today} Strict due:2014-01-01 rec:1d
\
n
"
.
format
(
today
=
self
.
today
)
result
=
"| 1
2
| {today} Strict due:2014-01-02 rec:1d
\
n
Completed: x {today} Strict due:2014-01-01 rec:1d
\
n
"
.
format
(
today
=
self
.
today
)
self
.
assertEqual
(
self
.
output
,
result
)
def
test_invalid1
(
self
):
...
...
@@ -254,7 +256,7 @@ class DoCommandTest(CommandTest):
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
"| 1
0
| {today} Recurring! rec:1d due:{today}
\
n
Completed: x {yesterday} Recurring! rec:1d
\
n
"
.
format
(
today
=
self
.
today
,
yesterday
=
self
.
yesterday
))
self
.
assertEqual
(
self
.
output
,
"| 1
2
| {today} Recurring! rec:1d due:{today}
\
n
Completed: x {yesterday} Recurring! rec:1d
\
n
"
.
format
(
today
=
self
.
today
,
yesterday
=
self
.
yesterday
))
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_do_custom_date6
(
self
):
...
...
@@ -267,7 +269,7 @@ class DoCommandTest(CommandTest):
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
"| 1
0
| {today} Recurring! rec:1d due:{today}
\
n
Completed: x {yesterday} Recurring! rec:1d
\
n
"
.
format
(
today
=
self
.
today
,
yesterday
=
self
.
yesterday
))
self
.
assertEqual
(
self
.
output
,
"| 1
2
| {today} Recurring! rec:1d due:{today}
\
n
Completed: x {yesterday} Recurring! rec:1d
\
n
"
.
format
(
today
=
self
.
today
,
yesterday
=
self
.
yesterday
))
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_do_custom_date7
(
self
):
...
...
@@ -279,7 +281,7 @@ class DoCommandTest(CommandTest):
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
"| 1
0
| {today} Strict due:2014-01-02 rec:1d
\
n
Completed: x {yesterday} Strict due:2014-01-01 rec:1d
\
n
"
.
format
(
today
=
self
.
today
,
yesterday
=
self
.
yesterday
))
self
.
assertEqual
(
self
.
output
,
"| 1
2
| {today} Strict due:2014-01-02 rec:1d
\
n
Completed: x {yesterday} Strict due:2014-01-01 rec:1d
\
n
"
.
format
(
today
=
self
.
today
,
yesterday
=
self
.
yesterday
))
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_multi_do1
(
self
):
...
...
@@ -320,10 +322,10 @@ class DoCommandTest(CommandTest):
"""
Check output when all supplied todo numbers are invalid.
"""
command
=
DoCommand
([
"99"
,
"1
0
"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_no_prompt
)
command
=
DoCommand
([
"99"
,
"1
5
"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_no_prompt
)
command
.
execute
()
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given: 99.
\
n
Invalid todo number given: 1
0
.
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given: 99.
\
n
Invalid todo number given: 1
5
.
\
n
"
)
def
test_multi_do6
(
self
):
""" Throw an error with invalid argument containing special characters. """
...
...
@@ -333,6 +335,46 @@ class DoCommandTest(CommandTest):
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
def
test_expr_do1
(
self
):
command
=
DoCommand
([
"-e"
,
"@test"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
"Completed: x {t} a @test with due:2015-06-03
\
n
Completed: x {t} a @test with +project
\
n
"
.
format
(
t
=
self
.
today
))
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_expr_do2
(
self
):
command
=
DoCommand
([
"-e"
,
"@test"
,
"due:2015-06-03"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
"Completed: x {} a @test with due:2015-06-03
\
n
"
.
format
(
self
.
today
))
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_expr_do3
(
self
):
command
=
DoCommand
([
"-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_do4
(
self
):
""" Don't do anything with unrelevant todo items. """
command
=
DoCommand
([
"-e"
,
"Foo"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
def
test_expr_do5
(
self
):
""" Force marking unrelevant items as done with additional -x flag. """
command
=
DoCommand
([
"-xe"
,
"Foo"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_yes_prompt
)
command
.
execute
()
result
=
"| 2| Bar p:1
\
n
| 3| Baz p:1
\
n
Completed: x {t} Bar p:1
\
n
Completed: x {t} Baz p:1
\
n
Completed: x {t} Foo id:1
\
n
"
.
format
(
t
=
self
.
today
)
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
result
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_invalid_recurrence
(
self
):
""" Show error message when an item has an invalid recurrence pattern. """
command
=
DoCommand
([
"9"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_no_prompt
)
...
...
test/PostponeCommandTest.py
View file @
4d049970
...
...
@@ -37,6 +37,7 @@ class PostponeCommandTest(CommandTest):
"Baz due:{} t:{}"
.
format
(
self
.
today
.
isoformat
(),
self
.
start
.
isoformat
()),
"Past due:{}"
.
format
(
self
.
past
.
isoformat
()),
"Future due:{} t:{}"
.
format
(
self
.
future
.
isoformat
(),
self
.
future_start
.
isoformat
()),
"FutureStart t:{}"
.
format
(
self
.
future
.
isoformat
())
]
self
.
todolist
=
TodoList
(
todos
)
...
...
@@ -233,6 +234,55 @@ class PostponeCommandTest(CommandTest):
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
def
test_expr_postpone1
(
self
):
command
=
PostponeCommand
([
"-e"
,
"due:tod"
,
"2w"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
due
=
self
.
today
+
timedelta
(
14
)
result
=
"| 2| Bar due:{d}
\
n
| 3| Baz due:{d} t:{s}
\
n
"
.
format
(
d
=
due
.
isoformat
(),
s
=
self
.
start
.
isoformat
())
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
result
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_expr_postpone2
(
self
):
cmd_args
=
[
"-e"
,
"t:{}"
.
format
(
self
.
start
.
isoformat
()),
"due:tod"
,
"1w"
]
command
=
PostponeCommand
(
cmd_args
,
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
due
=
self
.
today
+
timedelta
(
7
)
result
=
"| 3| Baz due:{} t:{}
\
n
"
.
format
(
due
.
isoformat
(),
self
.
start
.
isoformat
())
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
result
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_expr_postpone3
(
self
):
command
=
PostponeCommand
([
"-e"
,
"@test"
,
"due:tod"
,
"+project"
,
"C"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
def
test_expr_postpone4
(
self
):
""" Don't postpone unrelevant todo items. """
command
=
PostponeCommand
([
"-e"
,
"FutureStart"
,
"1w"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
def
test_expr_postpone5
(
self
):
""" Force postponing unrelevant items with additional -x flag. """
command
=
PostponeCommand
([
"-xe"
,
"FutureStart"
,
"1w"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
due
=
self
.
today
+
timedelta
(
7
)
result
=
"| 6| FutureStart t:{} due:{}
\
n
"
.
format
(
self
.
future
.
isoformat
(),
due
.
isoformat
())
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
result
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_help
(
self
):
command
=
PostponeCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
test/PriorityCommandTest.py
View file @
4d049970
...
...
@@ -27,6 +27,9 @@ class PriorityCommandTest(CommandTest):
todos
=
[
"(A) Foo"
,
"Bar"
,
"(B) a @test with due:2015-06-03"
,
"a @test with +project p:1"
,
"Baz id:1"
,
]
self
.
todolist
=
TodoList
(
todos
)
...
...
@@ -71,6 +74,49 @@ class PriorityCommandTest(CommandTest):
self
.
assertEqual
(
self
.
output
,
"Priority changed from A to C
\
n
| 1| (C) Foo
\
n
Priority set to C.
\
n
| 2| (C) Bar
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_expr_prio1
(
self
):
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
"
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
result
)
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
.
execute
()
result
=
"Priority changed from B to C
\
n
| 3| (C) a @test with due:2015-06-03
\
n
"
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
result
)
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
.
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
.
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
.
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
.
errors
,
""
)
def
test_invalid1
(
self
):
command
=
PriorityCommand
([
"99"
,
"A"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
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