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
37ffafe8
Commit
37ffafe8
authored
May 18, 2015
by
Jacek Sowiński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for bugs fixed in
cf3171c2
and
d606d862
parent
cf3171c2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
7 deletions
+81
-7
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
No files found.
test/DeleteCommandTest.py
View file @
37ffafe8
...
...
@@ -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 @
37ffafe8
...
...
@@ -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 @
37ffafe8
...
...
@@ -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 @
37ffafe8
...
...
@@ -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 @
37ffafe8
...
...
@@ -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 @
37ffafe8
...
...
@@ -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
()
...
...
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