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
57e89685
Commit
57e89685
authored
Nov 08, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Throw InvalidTodoException when the regex doesn't have exactly 1 hit.
parent
a7d51550
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
9 deletions
+13
-9
test/DeleteCommandTest.py
test/DeleteCommandTest.py
+1
-1
test/DoCommandTest.py
test/DoCommandTest.py
+1
-1
test/TodoListTest.py
test/TodoListTest.py
+2
-2
topydo/lib/DCommand.py
topydo/lib/DCommand.py
+7
-5
topydo/lib/TodoList.py
topydo/lib/TodoList.py
+2
-0
No files found.
test/DeleteCommandTest.py
View file @
57e89685
...
...
@@ -86,7 +86,7 @@ class DeleteCommandTest(CommandTest.CommandTest):
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
"Invalid todo number given.
\
n
"
)
def
test_empty
(
self
):
command
=
DeleteCommand
.
DeleteCommand
([],
self
.
todolist
,
self
.
out
,
self
.
error
)
...
...
test/DoCommandTest.py
View file @
57e89685
...
...
@@ -138,7 +138,7 @@ class DoCommandTest(CommandTest.CommandTest):
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
output
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
"Invalid todo number given.
\
n
"
)
def
test_activated_todos1
(
self
):
command
=
DoCommand
.
DoCommand
([
"2"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
...
...
test/TodoListTest.py
View file @
57e89685
...
...
@@ -182,11 +182,11 @@ class TodoListTester(unittest.TestCase):
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
def
test_regex1
(
self
):
self
.
assert
False
(
self
.
todolist
.
todo
(
"1"
)
)
self
.
assert
Raises
(
TodoList
.
InvalidTodoException
,
self
.
todolist
.
todo
,
"1"
)
def
test_regex2
(
self
):
""" Multiple hits should result in None. """
self
.
assert
False
(
self
.
todolist
.
todo
(
"Project1"
)
)
self
.
assert
Raises
(
TodoList
.
InvalidTodoException
,
self
.
todolist
.
todo
,
"Project1"
)
def
test_regex3
(
self
):
todo
=
self
.
todolist
.
todo
(
"project2"
)
...
...
topydo/lib/DCommand.py
View file @
57e89685
...
...
@@ -41,9 +41,11 @@ class DCommand(Command):
except
(
InvalidCommandArgument
,
InvalidTodoException
):
self
.
todo
=
None
except
InvalidTodoNumberException
:
self
.
todo
=
self
.
todolist
.
todo
(
self
.
argument
(
0
))
if
self
.
todo
:
try
:
self
.
todo
=
self
.
todolist
.
todo
(
self
.
argument
(
0
))
self
.
number
=
self
.
todolist
.
number
(
self
.
todo
)
except
InvalidTodoException
:
self
.
todo
=
None
def
_uncompleted_children
(
self
,
p_todo
):
return
sorted
([
t
for
t
in
self
.
todolist
.
children
(
p_todo
)
if
not
t
.
is_completed
()])
...
...
@@ -115,16 +117,16 @@ class DCommand(Command):
if
not
super
(
DCommand
,
self
).
execute
():
return
False
if
not
self
.
number
:
if
len
(
self
.
args
)
==
0
:
self
.
error
(
self
.
usage
())
elif
not
self
.
todo
:
self
.
error
(
"Invalid todo number given."
)
elif
self
.
todo
and
self
.
condition
():
old_active
=
self
.
_active_todos
()
self
.
_process_subtasks
()
self
.
execute_specific
()
current_active
=
self
.
_active_todos
()
self
.
_print_unlocked_todos
(
old_active
,
current_active
)
elif
not
self
.
todo
:
self
.
error
(
"Invalid todo number given."
)
else
:
self
.
error
(
self
.
condition_failed_text
())
topydo/lib/TodoList.py
View file @
57e89685
...
...
@@ -78,6 +78,8 @@ class TodoList(object):
if
len
(
candidates
)
==
1
:
result
=
candidates
[
0
]
else
:
raise
InvalidTodoException
return
result
...
...
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