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
c4189bb0
Commit
c4189bb0
authored
Oct 12, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests and adjustments for AppendCommand.
parent
9d97eb31
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
8 deletions
+73
-8
AppendCommand.py
AppendCommand.py
+13
-6
Command.py
Command.py
+2
-1
Utils.py
Utils.py
+1
-1
test/AppendCommandTest.py
test/AppendCommandTest.py
+57
-0
No files found.
AppendCommand.py
View file @
c4189bb0
...
...
@@ -10,10 +10,17 @@ class AppendCommand(Command.Command):
super
(
AppendCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
=
lambda
a
:
None
)
def
execute
(
self
):
number
=
convert_todo_number
(
self
.
argument
(
0
))
text
=
self
.
argument
(
1
)
number
=
self
.
argument
(
0
)
if
number
:
number
=
convert_todo_number
(
number
)
text
=
" "
.
join
(
self
.
args
[
1
:])
todo
=
self
.
todolist
.
todo
(
number
)
self
.
todolist
.
append
(
number
,
text
)
self
.
out
(
pretty_print
(
todo
,
[
self
.
todolist
.
pp_number
()]))
if
number
and
text
:
todo
=
self
.
todolist
.
todo
(
number
)
if
todo
:
self
.
todolist
.
append
(
number
,
text
)
self
.
out
(
pretty_print
(
todo
,
[
self
.
todolist
.
pp_number
()]))
else
:
self
.
error
(
"Invalid todo number given."
)
else
:
self
.
error
(
self
.
usage
())
Command.py
View file @
c4189bb0
...
...
@@ -39,10 +39,11 @@ class Command(object):
def
argument
(
self
,
p_number
):
""" Retrieves a value from the argument list at the given position. """
value
=
None
try
:
value
=
self
.
args
[
p_number
]
except
IndexError
:
self
.
usage
(
)
self
.
error
(
self
.
usage
()
)
return
value
...
...
Utils.py
View file @
c4189bb0
...
...
@@ -31,7 +31,7 @@ def convert_todo_number(p_number):
try
:
p_number
=
int
(
p_number
)
except
ValueError
:
error
(
"Invalid todo number given."
)
p_number
=
None
return
p_number
...
...
test/AppendCommandTest.py
0 → 100644
View file @
c4189bb0
import
AppendCommand
import
CommandTest
import
TodoList
class
AppendCommandTest
(
CommandTest
.
CommandTest
):
def
setUp
(
self
):
self
.
todolist
=
TodoList
.
TodoList
([])
self
.
todolist
.
add
(
"Foo"
)
def
test_append1
(
self
):
command
=
AppendCommand
.
AppendCommand
([
1
,
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
" 1 Foo Bar
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_append2
(
self
):
command
=
AppendCommand
.
AppendCommand
([
2
,
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given.
\
n
"
)
def
test_append3
(
self
):
command
=
AppendCommand
.
AppendCommand
([
1
,
""
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
output
,
""
)
def
test_append4
(
self
):
command
=
AppendCommand
.
AppendCommand
([
1
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
test_append5
(
self
):
command
=
AppendCommand
.
AppendCommand
([
1
,
"Bar"
,
"Baz"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
" 1 Foo Bar Baz
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_append6
(
self
):
command
=
AppendCommand
.
AppendCommand
([],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
test_append7
(
self
):
command
=
AppendCommand
.
AppendCommand
([
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
err
)
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
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