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
83b84fa5
Commit
83b84fa5
authored
May 19, 2015
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #23 from mruwek/prompt-unicode-fixes
Unicode fixes for prompt branch
parents
6cbeaf5d
37ffafe8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
88 additions
and
10 deletions
+88
-10
test/DeleteCommandTest.py
test/DeleteCommandTest.py
+10
-0
test/DepriCommandTest.py
test/DepriCommandTest.py
+10
-0
test/DoCommandTest.py
test/DoCommandTest.py
+9
-0
test/EditCommandTest.py
test/EditCommandTest.py
+32
-7
test/PostponeCommandTest.py
test/PostponeCommandTest.py
+10
-0
test/PriorityCommandTest.py
test/PriorityCommandTest.py
+10
-0
topydo/commands/EditCommand.py
topydo/commands/EditCommand.py
+4
-2
topydo/lib/MultiCommand.py
topydo/lib/MultiCommand.py
+3
-1
No files found.
test/DeleteCommandTest.py
View file @
83b84fa5
...
...
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
unittest
from
six
import
u
from
test.CommandTest
import
CommandTest
from
topydo.lib.Config
import
config
...
...
@@ -150,6 +151,15 @@ class DeleteCommandTest(CommandTest):
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given: 99.
\
n
Invalid todo number given: A.
\
n
"
)
def
test_multi_del5
(
self
):
""" Throw an error with invalid argument containing special characters. """
command
=
DeleteCommand
([
u
(
"Fo
\
u00d3
B
\
u0105
r"
),
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
def
test_empty
(
self
):
command
=
DeleteCommand
([],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
test/DepriCommandTest.py
View file @
83b84fa5
...
...
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
unittest
from
six
import
u
from
topydo.commands.DepriCommand
import
DepriCommand
from
test.CommandTest
import
CommandTest
...
...
@@ -93,6 +94,15 @@ class DepriCommandTest(CommandTest):
self
.
assertFalse
(
self
.
output
)
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given: 99.
\
n
Invalid todo number given: FooBar.
\
n
"
)
def
test_invalid4
(
self
):
""" Throw an error with invalid argument containing special characters. """
command
=
DepriCommand
([
u
(
"Fo
\
u00d3
B
\
u0105
r"
),
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
output
)
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
def
test_empty
(
self
):
command
=
DepriCommand
([],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
test/DoCommandTest.py
View file @
83b84fa5
...
...
@@ -16,6 +16,7 @@
from
datetime
import
date
,
timedelta
import
unittest
from
six
import
u
from
topydo.commands.DoCommand
import
DoCommand
from
test.CommandTest
import
CommandTest
...
...
@@ -324,6 +325,14 @@ class DoCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given: 99.
\
n
Invalid todo number given: 10.
\
n
"
)
def
test_multi_do6
(
self
):
""" Throw an error with invalid argument containing special characters. """
command
=
DoCommand
([
u
(
"Fo
\
u00d3
B
\
u0105
r"
),
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
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/EditCommandTest.py
View file @
83b84fa5
...
...
@@ -16,9 +16,10 @@
import
unittest
import
mock
from
six
import
u
from
topydo.commands.EditCommand
import
EditCommand
from
test.CommandTest
import
CommandTest
from
test.CommandTest
import
CommandTest
,
utf8
from
topydo.lib.TodoList
import
TodoList
from
topydo.lib.Todo
import
Todo
...
...
@@ -29,6 +30,7 @@ class EditCommandTest(CommandTest):
"Foo id:1"
,
"Bar p:1 @test"
,
"Baz @test"
,
u
(
"Fo
\
u00f3
B
\
u0105
\
u017a
"
),
]
self
.
todolist
=
TodoList
(
todos
)
...
...
@@ -44,7 +46,7 @@ class EditCommandTest(CommandTest):
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
errors
,
""
)
self
.
assertEqual
(
str
(
self
.
todolist
),
"Bar p:1 @test
\
n
Baz @test
\
n
Foo id:1"
)
self
.
assertEqual
(
str
(
self
.
todolist
),
utf8
(
u
(
"Bar p:1 @test
\
n
Baz @test
\
n
Fo
\
u00f3
B
\
u0105
\
u017a
\
n
Foo id:1"
))
)
@
mock
.
patch
(
'topydo.commands.EditCommand.EditCommand._todos_from_temp'
)
@
mock
.
patch
(
'topydo.commands.EditCommand.EditCommand._open_in_editor'
)
...
...
@@ -58,7 +60,7 @@ class EditCommandTest(CommandTest):
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
errors
,
""
)
self
.
assertEqual
(
str
(
self
.
todolist
),
"Foo id:1
\
n
Baz @test
\
n
Lazy Cat"
)
self
.
assertEqual
(
str
(
self
.
todolist
),
utf8
(
u
(
"Foo id:1
\
n
Baz @test
\
n
Fo
\
u00f3
B
\
u0105
\
u017a
\
n
Lazy Cat"
))
)
def
test_edit3
(
self
):
""" Throw an error after invalid todo number given as argument. """
...
...
@@ -70,11 +72,11 @@ class EditCommandTest(CommandTest):
def
test_edit4
(
self
):
""" Throw an error with pointing invalid argument. """
command
=
EditCommand
([
"Bar"
,
"
4
"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
=
EditCommand
([
"Bar"
,
"
5
"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given:
4
.
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given:
5
.
\
n
"
)
@
mock
.
patch
(
'topydo.commands.EditCommand.EditCommand._todos_from_temp'
)
@
mock
.
patch
(
'topydo.commands.EditCommand.EditCommand._open_in_editor'
)
...
...
@@ -88,7 +90,30 @@ class EditCommandTest(CommandTest):
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
errors
,
"Number of edited todos is not equal to number of supplied todo IDs.
\
n
"
)
self
.
assertEqual
(
str
(
self
.
todolist
),
"Foo id:1
\
n
Bar p:1 @test
\
n
Baz @test"
)
self
.
assertEqual
(
str
(
self
.
todolist
),
utf8
(
u
(
"Foo id:1
\
n
Bar p:1 @test
\
n
Baz @test
\
n
Fo
\
u00f3
B
\
u0105
\
u017a
"
)))
def
test_edit6
(
self
):
""" Throw an error with invalid argument containing special characters. """
command
=
EditCommand
([
u
(
"Fo
\
u00d3
B
\
u0105
r"
),
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
@
mock
.
patch
(
'topydo.commands.EditCommand.EditCommand._todos_from_temp'
)
@
mock
.
patch
(
'topydo.commands.EditCommand.EditCommand._open_in_editor'
)
def
test_edit7
(
self
,
mock_open_in_editor
,
mock_todos_from_temp
):
""" Edit todo with special characters. """
mock_open_in_editor
.
return_value
=
0
mock_todos_from_temp
.
return_value
=
[
Todo
(
'Lazy Cat'
)]
command
=
EditCommand
([
u
(
"Fo
\
u00f3
B
\
u0105
\
u017a
"
)],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
errors
,
""
)
self
.
assertEqual
(
str
(
self
.
todolist
),
utf8
(
u
(
"Foo id:1
\
n
Bar p:1 @test
\
n
Baz @test
\
n
Lazy Cat"
)))
@
mock
.
patch
(
'topydo.commands.EditCommand.EditCommand._todos_from_temp'
)
@
mock
.
patch
(
'topydo.commands.EditCommand.EditCommand._open_in_editor'
)
...
...
@@ -102,7 +127,7 @@ class EditCommandTest(CommandTest):
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
errors
,
""
)
self
.
assertEqual
(
str
(
self
.
todolist
),
"Foo id:1
\
n
Lazy Cat
\
n
Lazy Dog"
)
self
.
assertEqual
(
str
(
self
.
todolist
),
utf8
(
u
(
"Foo id:1
\
n
Fo
\
u00f3
B
\
u0105
\
u017a
\
n
Lazy Cat
\
n
Lazy Dog"
))
)
if
__name__
==
'__main__'
:
unittest
.
main
()
test/PostponeCommandTest.py
View file @
83b84fa5
...
...
@@ -16,6 +16,7 @@
from
datetime
import
date
,
timedelta
import
unittest
from
six
import
u
from
topydo.commands.PostponeCommand
import
PostponeCommand
from
test.CommandTest
import
CommandTest
...
...
@@ -219,6 +220,15 @@ class PostponeCommandTest(CommandTest):
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given: Zoo.
\
n
Invalid todo number given: 99.
\
n
Invalid todo number given: 123.
\
n
"
)
def
test_postpone20
(
self
):
""" Throw an error with invalid argument containing special characters. """
command
=
PostponeCommand
([
u
(
"Fo
\
u00d3
B
\
u0105
r"
),
"Bar"
,
"1d"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
def
test_help
(
self
):
command
=
PostponeCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
test/PriorityCommandTest.py
View file @
83b84fa5
...
...
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
unittest
from
six
import
u
from
topydo.commands.PriorityCommand
import
PriorityCommand
from
test.CommandTest
import
CommandTest
...
...
@@ -118,6 +119,15 @@ class PriorityCommandTest(CommandTest):
self
.
assertFalse
(
self
.
output
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
test_invalid7
(
self
):
""" Throw an error with invalid argument containing special characters. """
command
=
PriorityCommand
([
u
(
"Fo
\
u00d3
B
\
u0105
r"
),
"Bar"
,
"C"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
def
test_empty
(
self
):
command
=
PriorityCommand
([],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
topydo/commands/EditCommand.py
View file @
83b84fa5
...
...
@@ -18,6 +18,8 @@ import os
from
subprocess
import
call
,
check_call
,
CalledProcessError
import
tempfile
from
six
import
text_type
,
u
from
topydo.commands.ListCommand
import
ListCommand
from
topydo.lib.MultiCommand
import
MultiCommand
from
topydo.lib.Config
import
config
...
...
@@ -50,7 +52,7 @@ class EditCommand(MultiCommand, ListCommand):
def
_todos_to_temp
(
self
):
f
=
tempfile
.
NamedTemporaryFile
()
for
todo
in
self
.
todos
:
f
.
write
((
str
(
todo
)
+
"
\
n
"
).
encode
(
'utf-8'
))
f
.
write
((
text_type
(
todo
)
+
"
\
n
"
).
encode
(
'utf-8'
))
f
.
seek
(
0
)
return
f
...
...
@@ -77,7 +79,7 @@ class EditCommand(MultiCommand, ListCommand):
if
len
(
self
.
invalid_numbers
)
>
1
or
len
(
self
.
invalid_numbers
)
>
0
and
len
(
self
.
todos
)
>
0
:
for
number
in
self
.
invalid_numbers
:
errors
.
append
(
"Invalid todo number given: {}."
.
format
(
number
))
errors
.
append
(
u
(
"Invalid todo number given: {}."
)
.
format
(
number
))
elif
len
(
self
.
invalid_numbers
)
==
1
and
len
(
self
.
todos
)
==
0
:
errors
.
append
(
"Invalid todo number given."
)
...
...
topydo/lib/MultiCommand.py
View file @
83b84fa5
...
...
@@ -14,6 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
six
import
u
from
topydo.lib.Command
import
Command
from
topydo.lib.TodoListBase
import
InvalidTodoException
...
...
@@ -52,7 +54,7 @@ class MultiCommand(Command):
if
len
(
self
.
invalid_numbers
)
>
1
or
len
(
self
.
invalid_numbers
)
>
0
and
len
(
self
.
todos
)
>
0
:
for
number
in
self
.
invalid_numbers
:
errors
.
append
(
"Invalid todo number given: {}."
.
format
(
number
))
errors
.
append
(
u
(
"Invalid todo number given: {}."
)
.
format
(
number
))
elif
len
(
self
.
invalid_numbers
)
==
1
and
len
(
self
.
todos
)
==
0
:
errors
.
append
(
"Invalid todo number given."
)
elif
len
(
self
.
todos
)
==
0
and
len
(
self
.
invalid_numbers
)
==
0
:
...
...
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