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
3c7ef04b
Commit
3c7ef04b
authored
Oct 18, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make DoCommandTest a bit more elaborate.
parent
f5d8302b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
8 deletions
+31
-8
test/DoCommandTest.py
test/DoCommandTest.py
+31
-8
No files found.
test/DoCommandTest.py
View file @
3c7ef04b
...
@@ -12,19 +12,23 @@ def _no_prompt(self):
...
@@ -12,19 +12,23 @@ def _no_prompt(self):
class
DoCommandTest
(
CommandTest
.
CommandTest
):
class
DoCommandTest
(
CommandTest
.
CommandTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
todolist
=
TodoList
.
TodoList
([])
todos
=
[
"Foo id:1"
,
"Bar p:1"
,
"Baz p:1"
,
"Recurring! rec:1d"
,
"x 2014-10-18 Already complete"
,
]
self
.
todolist
=
TodoList
.
TodoList
(
todos
)
self
.
today
=
date
.
today
().
isoformat
()
self
.
today
=
date
.
today
().
isoformat
()
self
.
todolist
.
add
(
"Foo id:1"
)
self
.
todolist
.
add
(
"Bar p:1"
)
self
.
todolist
.
add
(
"Baz p:1"
)
self
.
todolist
.
add
(
"Recurring! rec:1d"
)
self
.
todolist
.
add
(
"x 2014-10-18 Already complete"
)
def
test_do1
(
self
):
def
test_do1
(
self
):
command
=
DoCommand
.
DoCommand
([
"3"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_no_prompt
)
command
=
DoCommand
.
DoCommand
([
"3"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
_no_prompt
)
command
.
execute
()
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertTrue
(
self
.
todolist
.
todo
(
3
).
is_completed
())
self
.
assertEquals
(
self
.
output
,
"x %s Baz p:1
\
n
"
%
self
.
today
)
self
.
assertEquals
(
self
.
output
,
"x %s Baz p:1
\
n
"
%
self
.
today
)
self
.
assertEquals
(
self
.
errors
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
...
@@ -34,6 +38,11 @@ class DoCommandTest(CommandTest.CommandTest):
...
@@ -34,6 +38,11 @@ class DoCommandTest(CommandTest.CommandTest):
result
=
" 2 Bar p:1
\
n
3 Baz p:1
\
n
x %s Bar p:1
\
n
x %s Baz p:1
\
n
x %s Foo id:1
\
n
"
%
(
self
.
today
,
self
.
today
,
self
.
today
)
result
=
" 2 Bar p:1
\
n
3 Baz p:1
\
n
x %s Bar p:1
\
n
x %s Baz p:1
\
n
x %s Foo id:1
\
n
"
%
(
self
.
today
,
self
.
today
,
self
.
today
)
for
number
in
[
1
,
2
,
3
]:
self
.
assertTrue
(
self
.
todolist
.
todo
(
number
).
is_completed
())
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
todolist
.
todo
(
4
).
is_completed
())
self
.
assertEquals
(
self
.
output
,
result
)
self
.
assertEquals
(
self
.
output
,
result
)
self
.
assertEquals
(
self
.
errors
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
...
@@ -43,25 +52,36 @@ class DoCommandTest(CommandTest.CommandTest):
...
@@ -43,25 +52,36 @@ class DoCommandTest(CommandTest.CommandTest):
result
=
" 2 Bar p:1
\
n
3 Baz p:1
\
n
x %s Foo id:1
\
n
"
%
self
.
today
result
=
" 2 Bar p:1
\
n
3 Baz p:1
\
n
x %s Foo id:1
\
n
"
%
self
.
today
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertTrue
(
self
.
todolist
.
todo
(
1
).
is_completed
())
self
.
assertFalse
(
self
.
todolist
.
todo
(
2
).
is_completed
())
self
.
assertFalse
(
self
.
todolist
.
todo
(
3
).
is_completed
())
self
.
assertEquals
(
self
.
output
,
result
)
self
.
assertEquals
(
self
.
output
,
result
)
self
.
assertEquals
(
self
.
errors
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_recurrence
(
self
):
def
test_recurrence
(
self
):
command
=
DoCommand
.
DoCommand
([
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DoCommand
.
DoCommand
([
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
self
.
assertFalse
(
self
.
todolist
.
todo
(
4
).
has_tag
(
'due'
))
command
.
execute
()
command
.
execute
()
todo
=
self
.
todolist
.
todo
(
6
)
result
=
" 6 2014-10-18 Recurring! rec:1d due:2014-10-19
\
n
x 2014-10-18 Recurring! rec:1d
\
n
"
result
=
" 6 2014-10-18 Recurring! rec:1d due:2014-10-19
\
n
x 2014-10-18 Recurring! rec:1d
\
n
"
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
result
)
self
.
assertEquals
(
self
.
output
,
result
)
self
.
assertEquals
(
self
.
errors
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
self
.
assertEquals
(
self
.
todolist
.
count
(),
6
)
self
.
assertEquals
(
self
.
todolist
.
count
(),
6
)
self
.
assertTrue
(
self
.
todolist
.
todo
(
4
).
is_completed
())
self
.
assertTrue
(
self
.
todolist
.
todo
(
4
).
is_completed
())
self
.
assertFalse
(
self
.
todolist
.
todo
(
6
).
is_completed
())
self
.
assertFalse
(
todo
.
is_completed
())
self
.
assertTrue
(
todo
.
has_tag
(
'due'
))
def
test_invalid1
(
self
):
def
test_invalid1
(
self
):
command
=
DoCommand
.
DoCommand
([
"99"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DoCommand
.
DoCommand
([
"99"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
output
)
self
.
assertFalse
(
self
.
output
)
self
.
assertEquals
(
self
.
errors
,
"Invalid todo number given.
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
"Invalid todo number given.
\
n
"
)
...
@@ -69,6 +89,7 @@ class DoCommandTest(CommandTest.CommandTest):
...
@@ -69,6 +89,7 @@ class DoCommandTest(CommandTest.CommandTest):
command
=
DoCommand
.
DoCommand
([
"A"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DoCommand
.
DoCommand
([
"A"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
output
)
self
.
assertFalse
(
self
.
output
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
...
@@ -76,6 +97,7 @@ class DoCommandTest(CommandTest.CommandTest):
...
@@ -76,6 +97,7 @@ class DoCommandTest(CommandTest.CommandTest):
command
=
DoCommand
.
DoCommand
([
"5"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DoCommand
.
DoCommand
([
"5"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
output
)
self
.
assertFalse
(
self
.
output
)
self
.
assertEquals
(
self
.
errors
,
"Todo has already been completed.
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
"Todo has already been completed.
\
n
"
)
...
@@ -83,5 +105,6 @@ class DoCommandTest(CommandTest.CommandTest):
...
@@ -83,5 +105,6 @@ class DoCommandTest(CommandTest.CommandTest):
command
=
DoCommand
.
DoCommand
([
""
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DoCommand
.
DoCommand
([
""
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
output
)
self
.
assertFalse
(
self
.
output
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
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