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
7c7a7169
Commit
7c7a7169
authored
Oct 12, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for AddCommand.
parent
ca323e67
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
176 additions
and
0 deletions
+176
-0
test/AddCommandTest.py
test/AddCommandTest.py
+163
-0
test/CommandTest.py
test/CommandTest.py
+13
-0
No files found.
test/AddCommandTest.py
0 → 100644
View file @
7c7a7169
from
datetime
import
date
import
AddCommand
import
CommandTest
import
TodoList
class
AddCommandTest
(
CommandTest
.
CommandTest
):
def
setUp
(
self
):
self
.
todolist
=
TodoList
.
TodoList
([])
self
.
today
=
date
.
today
().
isoformat
()
def
test_add_task
(
self
):
args
=
[
"New todo"
]
command
=
AddCommand
.
AddCommand
(
args
,
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
source
(),
self
.
today
+
" New todo"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add_multiple_args
(
self
):
args
=
[
"New"
,
"todo"
]
command
=
AddCommand
.
AddCommand
(
args
,
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
source
(),
self
.
today
+
" New todo"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add_priority1
(
self
):
command
=
AddCommand
.
AddCommand
([
"Foo (C)"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
priority
(),
'C'
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
source
(),
"(C) "
+
self
.
today
+
" Foo"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add_priority2
(
self
):
command
=
AddCommand
.
AddCommand
([
"Foo (CC)"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
priority
(),
None
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
source
(),
self
.
today
+
" Foo (CC)"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add_priority3
(
self
):
command
=
AddCommand
.
AddCommand
([
"Fo(C)o"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
priority
(),
None
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
source
(),
self
.
today
+
" Fo(C)o"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add_priority4
(
self
):
command
=
AddCommand
.
AddCommand
([
"(C) Foo"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
priority
(),
'C'
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
source
(),
"(C) "
+
self
.
today
+
" Foo"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add_dep1
(
self
):
command
=
AddCommand
.
AddCommand
([
"Foo"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
command
=
AddCommand
.
AddCommand
([
"Bar before:1"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
source
(),
self
.
today
+
" Foo id:1"
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
2
).
source
(),
self
.
today
+
" Bar p:1"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add_dep2
(
self
):
command
=
AddCommand
.
AddCommand
([
"Foo"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
command
=
AddCommand
.
AddCommand
([
"Bar partof:1"
],
self
.
todolist
)
command
.
execute
()
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
source
(),
self
.
today
+
" Foo id:1"
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
2
).
source
(),
self
.
today
+
" Bar p:1"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add_dep3
(
self
):
command
=
AddCommand
.
AddCommand
([
"Foo"
],
self
.
todolist
)
command
.
execute
()
command
=
AddCommand
.
AddCommand
([
"Bar after:1"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
source
(),
self
.
today
+
" Foo p:1"
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
2
).
source
(),
self
.
today
+
" Bar id:1"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add_dep4
(
self
):
""" Test for using an after: tag with non-existing value. """
command
=
AddCommand
.
AddCommand
([
"Foo after:1"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
todo
(
1
).
has_tag
(
"after"
))
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
source
(),
self
.
today
+
" Foo"
)
self
.
assertEquals
(
self
.
output
,
" 1 "
+
str
(
self
.
todolist
.
todo
(
1
))
+
"
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add_dep4
(
self
):
""" Test for using an after: tag with non-existing value. """
command
=
AddCommand
.
AddCommand
([
"Foo after:2"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
todo
(
1
).
has_tag
(
"after"
))
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
source
(),
self
.
today
+
" Foo"
)
self
.
assertEquals
(
self
.
output
,
" 1 "
+
str
(
self
.
todolist
.
todo
(
1
))
+
"
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add_dep5
(
self
):
command
=
AddCommand
.
AddCommand
([
"Foo"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
command
=
AddCommand
.
AddCommand
([
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
command
=
AddCommand
.
AddCommand
([
"Baz before:1 before:2"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
source
(),
self
.
today
+
" Foo id:1"
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
2
).
source
(),
self
.
today
+
" Bar id:2"
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
3
).
source
(),
self
.
today
+
" Baz p:1 p:2"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add_dep6
(
self
):
command
=
AddCommand
.
AddCommand
([
"Foo"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
command
=
AddCommand
.
AddCommand
([
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
command
=
AddCommand
.
AddCommand
([
"Baz after:1 after:2"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
source
(),
self
.
today
+
" Foo p:1"
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
2
).
source
(),
self
.
today
+
" Bar p:1"
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
3
).
source
(),
self
.
today
+
" Baz id:1"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add_reldate1
(
self
):
command
=
AddCommand
.
AddCommand
([
"Foo due:today"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
source
(),
self
.
today
+
" Foo due:"
+
self
.
today
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add_reldate2
(
self
):
command
=
AddCommand
.
AddCommand
([
"Foo t:today due:today"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
result
=
" 1 %s Foo t:%s due:%s
\
n
"
%
(
self
.
today
,
self
.
today
,
self
.
today
)
self
.
assertEquals
(
self
.
output
,
result
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add_empty
(
self
):
command
=
AddCommand
.
AddCommand
([],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
test/CommandTest.py
0 → 100644
View file @
7c7a7169
import
unittest
class
CommandTest
(
unittest
.
TestCase
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
CommandTest
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
output
=
""
self
.
errors
=
""
def
out
(
self
,
p_output
):
self
.
output
+=
p_output
+
"
\
n
"
;
def
err
(
self
,
p_error
):
self
.
errors
+=
p_error
+
"
\
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