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
9f48c518
Commit
9f48c518
authored
May 28, 2015
by
Jacek Sowiński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for adding todos from file with `add -f`
parent
47479b6d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
+22
-2
test/AddCommandTest.py
test/AddCommandTest.py
+17
-0
test/data/AddCommandTest-from_file.txt
test/data/AddCommandTest-from_file.txt
+2
-0
topydo/commands/AddCommand.py
topydo/commands/AddCommand.py
+3
-2
No files found.
test/AddCommandTest.py
View file @
9f48c518
...
@@ -16,7 +16,9 @@
...
@@ -16,7 +16,9 @@
from
datetime
import
date
from
datetime
import
date
import
unittest
import
unittest
import
mock
from
six
import
u
from
six
import
u
from
io
import
StringIO
from
topydo.commands
import
AddCommand
from
topydo.commands
import
AddCommand
from
topydo.commands
import
ListCommand
from
topydo.commands
import
ListCommand
...
@@ -242,6 +244,21 @@ class AddCommandTest(CommandTest):
...
@@ -242,6 +244,21 @@ class AddCommandTest(CommandTest):
self
.
assertEqual
(
self
.
output
,
utf8
(
u
(
"| 1| {} Special
\
u25c4
\
n
"
).
format
(
self
.
today
)))
self
.
assertEqual
(
self
.
output
,
utf8
(
u
(
"| 1| {} Special
\
u25c4
\
n
"
).
format
(
self
.
today
)))
self
.
assertEqual
(
self
.
errors
,
""
)
self
.
assertEqual
(
self
.
errors
,
""
)
@
mock
.
patch
(
"topydo.commands.AddCommand.stdin"
,
StringIO
(
u
(
"Fo
\
u00f3
due:tod id:1
\
n
B
\
u0105
r before:1"
)))
def
test_add_from_stdin
(
self
):
command
=
AddCommand
.
AddCommand
([
"-f"
,
"-"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
utf8
(
u
(
"| 1| {tod} Fo
\
u00f3
due:{tod} id:1
\
n
| 2| {tod} B
\
u0105
r p:1
\
n
"
.
format
(
tod
=
self
.
today
))))
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_add_from_file
(
self
):
command
=
AddCommand
.
AddCommand
([
"-f"
,
"test/data/AddCommandTest-from_file.txt"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
utf8
(
u
(
"| 1| {tod} Foo @fo
\
u00f3
b
\
u0105
r due:{tod} id:1
\
n
| 2| {tod} Bar +baz t:{tod} p:1
\
n
"
.
format
(
tod
=
self
.
today
))))
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_help
(
self
):
def
test_help
(
self
):
command
=
AddCommand
.
AddCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
AddCommand
.
AddCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
command
.
execute
()
...
...
test/data/AddCommandTest-from_file.txt
0 → 100644
View file @
9f48c518
Foo @foóbąr due:tod id:1
Bar +baz t:tod before:1
topydo/commands/AddCommand.py
View file @
9f48c518
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
from
datetime
import
date
from
datetime
import
date
import
re
import
re
from
sys
import
stdin
from
sys
import
stdin
import
codecs
from
topydo.lib.Config
import
config
from
topydo.lib.Config
import
config
from
topydo.lib.Command
import
Command
from
topydo.lib.Command
import
Command
...
@@ -100,9 +101,9 @@ class AddCommand(Command):
...
@@ -100,9 +101,9 @@ class AddCommand(Command):
if
self
.
from_file
==
'-'
:
if
self
.
from_file
==
'-'
:
f
=
stdin
f
=
stdin
else
:
else
:
f
=
open
(
self
.
from_file
,
'r
'
)
f
=
codecs
.
open
(
self
.
from_file
,
'r'
,
encoding
=
'utf-8
'
)
todos
=
f
.
read
().
decode
(
'utf-8'
).
splitlines
()
todos
=
f
.
read
().
splitlines
()
return
todos
return
todos
...
...
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