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
9fdbde19
Commit
9fdbde19
authored
Feb 21, 2017
by
Bram Schoenmakers
Committed by
GitHub
Feb 21, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #169 from mruwek/before-after-dep-ls
Introduce 'before' and 'after' keywords to `dep ls`
parents
edc11eeb
67975f4b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
13 deletions
+49
-13
test/test_dep_command.py
test/test_dep_command.py
+38
-2
topydo/commands/DepCommand.py
topydo/commands/DepCommand.py
+11
-11
No files found.
test/test_dep_command.py
View file @
9fdbde19
...
...
@@ -271,6 +271,42 @@ class DepCommandTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given.
\
n
"
)
def
test_ls5
(
self
):
command
=
DepCommand
([
"ls"
,
"before"
,
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
dirty
)
self
.
assertEqual
(
self
.
output
,
"| 2| Bar p:1
\
n
| 3| Baz p:1
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_ls6
(
self
):
command
=
DepCommand
([
"ls"
,
"before"
,
"99"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
dirty
)
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given.
\
n
"
)
def
test_ls7
(
self
):
command
=
DepCommand
([
"ls"
,
"after"
,
"3"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
dirty
)
self
.
assertEqual
(
self
.
output
,
"| 1| Foo id:1
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_ls8
(
self
):
command
=
DepCommand
([
"ls"
,
"after"
,
"99"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
dirty
)
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
"Invalid todo number given.
\
n
"
)
def
test_ls9
(
self
):
command
=
DepCommand
([
"ls"
,
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
@@ -278,7 +314,7 @@ class DepCommandTest(CommandTest):
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
test_ls
6
(
self
):
def
test_ls
10
(
self
):
command
=
DepCommand
([
"ls"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
@@ -286,7 +322,7 @@ class DepCommandTest(CommandTest):
self
.
assertFalse
(
self
.
output
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
test_ls
7
(
self
):
def
test_ls
11
(
self
):
command
=
DepCommand
([
"ls"
,
"top"
,
"99"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
topydo/commands/DepCommand.py
View file @
9fdbde19
...
...
@@ -108,24 +108,23 @@ class DepCommand(Command):
arg2
=
self
.
argument
(
2
)
todos
=
[]
if
arg2
==
'to'
:
# dep ls 1 to
...
number
=
arg1
if
arg2
==
'to'
or
arg1
==
'before'
:
# dep ls 1 to
OR dep ls before 1
number
=
arg1
if
arg2
==
'to'
else
arg2
todo
=
self
.
todolist
.
todo
(
number
)
todos
=
self
.
todolist
.
children
(
todo
)
elif
arg1
==
'to'
:
# dep ls
... to
1
elif
arg1
in
{
'to'
,
'after'
}
:
# dep ls
to 1 OR dep ls after
1
number
=
arg2
todo
=
self
.
todolist
.
todo
(
number
)
todos
=
self
.
todolist
.
parents
(
todo
)
else
:
self
.
error
(
self
.
usage
())
raise
InvalidCommandArgument
if
todos
:
sorter
=
Sorter
(
config
().
sort_string
())
instance_filter
=
Filter
.
InstanceFilter
(
todos
)
view
=
View
(
sorter
,
[
instance_filter
],
self
.
todolist
)
self
.
out
(
self
.
printer
.
print_list
(
view
.
todos
))
sorter
=
Sorter
(
config
().
sort_string
())
instance_filter
=
Filter
.
InstanceFilter
(
todos
)
view
=
View
(
sorter
,
[
instance_filter
],
self
.
todolist
)
self
.
out
(
self
.
printer
.
print_list
(
view
.
todos
))
except
InvalidTodoException
:
self
.
error
(
"Invalid todo number given."
)
except
InvalidCommandArgument
:
...
...
@@ -176,6 +175,7 @@ class DepCommand(Command):
dep add <NUMBER> <before|partof|after|parents-of|children-of> <NUMBER>
dep ls <NUMBER> to
dep ls to <NUMBER>
dep ls <before|after> <NUMBER>
dep dot <NUMBER>
dep clean"""
...
...
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