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
3f59dae7
Commit
3f59dae7
authored
Oct 19, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for the ListCommand.
parent
bded7f71
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
4 deletions
+57
-4
ListCommand.py
ListCommand.py
+4
-4
test/ListCommandTest.py
test/ListCommandTest.py
+47
-0
test/data/ListCommandTest.txt
test/data/ListCommandTest.txt
+6
-0
No files found.
ListCommand.py
View file @
3f59dae7
...
@@ -11,12 +11,12 @@ class ListCommand(Command.Command):
...
@@ -11,12 +11,12 @@ class ListCommand(Command.Command):
super
(
ListCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
ListCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
def
execute
(
self
):
def
execute
(
self
):
show_all
=
self
.
argumentShift
(
"-x"
)
sorter
=
Sorter
.
Sorter
(
Config
.
SORT_STRING
)
sorter
=
Sorter
.
Sorter
(
Config
.
SORT_STRING
)
filters
=
[]
if
show_all
else
[
Filter
.
DependencyFilter
(
self
.
todolist
),
Filter
.
RelevanceFilter
()]
filters
=
[]
if
len
(
self
.
args
)
>
0
:
if
len
(
self
.
args
)
>
0
:
filters
=
[
Filter
.
GrepFilter
(
self
.
argument
(
0
))]
filters
.
append
(
Filter
.
GrepFilter
(
self
.
argument
(
0
)))
else
:
filters
=
[
Filter
.
DependencyFilter
(
self
.
todolist
),
Filter
.
RelevanceFilter
()]
self
.
out
(
self
.
todolist
.
view
(
sorter
,
filters
).
pretty_print
())
self
.
out
(
self
.
todolist
.
view
(
sorter
,
filters
).
pretty_print
())
test/ListCommandTest.py
0 → 100644
View file @
3f59dae7
import
CommandTest
import
ListCommand
import
TestFacilities
class
ListCommandTest
(
CommandTest
.
CommandTest
):
def
setUp
(
self
):
self
.
todolist
=
TestFacilities
.
load_file_to_todolist
(
"data/ListCommandTest.txt"
)
def
test_list1
(
self
):
command
=
ListCommand
.
ListCommand
([
""
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
" 1 (C) Foo @Context2 Not@Context +Project1 Not+Project
\
n
4 (C) Drink beer @ home
\
n
5 (C) 13 + 29 = 42
\
n
2 (D) Bar @Context1 +Project2 p:1
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_list3
(
self
):
command
=
ListCommand
.
ListCommand
([
"Context1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
" 2 (D) Bar @Context1 +Project2 p:1
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_list4
(
self
):
command
=
ListCommand
.
ListCommand
([
"-x"
,
"Context1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
" 3 (C) Baz @Context1 +Project1 key:value id:1
\
n
2 (D) Bar @Context1 +Project2 p:1
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_list5
(
self
):
command
=
ListCommand
.
ListCommand
([
"-x"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
" 1 (C) Foo @Context2 Not@Context +Project1 Not+Project
\
n
3 (C) Baz @Context1 +Project1 key:value id:1
\
n
4 (C) Drink beer @ home
\
n
5 (C) 13 + 29 = 42
\
n
2 (D) Bar @Context1 +Project2 p:1
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_list6
(
self
):
command
=
ListCommand
.
ListCommand
([
"Project3"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
test/data/ListCommandTest.txt
0 → 100644
View file @
3f59dae7
(C) Foo @Context2 Not@Context +Project1 Not+Project
(D) Bar @Context1 +Project2 p:1
(C) Baz @Context1 +Project1 key:value id:1
(C) Drink beer @ home
(C) 13 + 29 = 42
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