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
eac37bab
Commit
eac37bab
authored
Dec 06, 2016
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for groups
parent
e9411143
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
186 additions
and
0 deletions
+186
-0
test/data/ListCommandGroupTest.txt
test/data/ListCommandGroupTest.txt
+19
-0
test/test_list_command.py
test/test_list_command.py
+167
-0
No files found.
test/data/ListCommandGroupTest.txt
0 → 100644
View file @
eac37bab
+A only test:test_group1
+B only test:test_group1
+A and +B test:test_group1
No project test:test_group1
Different item test:test_group2 l:1
Another item test:test_group2 l:0
Test 1 due:2016-12-06 test:test_group3
Test 2 due:2016-12-07 test:test_group3
Test 1 t:2016-12-06 test:test_group4 test:test_group5
Test 2 t:2016-12-07 test:test_group4 test:test_group5
Group by non-existing tag test:test_group6
Sort descending +A test:test_group7
Sort descending +B test:test_group7
Inner sort 1 +A @A test:test_group8
Inner sort 2 +A @B test:test_group8
Inner sort 3 +B @A test:test_group8
Inner sort 4 +B @B test:test_group8
Inner sort 1 +A test:test_group9
Inner sort 2 +A test:test_group9
test/test_list_command.py
View file @
eac37bab
...
...
@@ -552,5 +552,172 @@ class ListCommandDotTest(CommandTest):
self
.
assertEqual
(
self
.
errors
,
""
)
@
freeze_time
(
'2016, 12, 6'
)
class
ListCommandGroupTest
(
CommandTest
):
def
test_group1
(
self
):
todolist
=
load_file_to_todolist
(
"test/data/ListCommandGroupTest.txt"
)
command
=
ListCommand
([
"-g"
,
"project"
,
"test:test_group1"
],
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
todolist
.
dirty
)
self
.
assertEqual
(
self
.
output
,
"""
\
Project: A
==========
| 1| +A only test:test_group1
| 3| +A and +B test:test_group1
Project: B
==========
| 3| +A and +B test:test_group1
| 2| +B only test:test_group1
Project: None
=============
| 4| No project test:test_group1
"""
)
def
test_group2
(
self
):
todolist
=
load_file_to_todolist
(
"test/data/ListCommandGroupTest.txt"
)
command
=
ListCommand
([
"-g"
,
"l"
,
"test:test_group2"
],
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
todolist
.
dirty
)
self
.
assertEqual
(
self
.
output
,
"""
\
l: 0
====
| 6| Another item l:0 test:test_group2
l: 1
====
| 5| Different item l:1 test:test_group2
"""
)
def
test_group3
(
self
):
todolist
=
load_file_to_todolist
(
"test/data/ListCommandGroupTest.txt"
)
command
=
ListCommand
([
"-g"
,
"due"
,
"test:test_group3"
],
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
todolist
.
dirty
)
self
.
assertEqual
(
self
.
output
,
"""
\
due: today
==========
| 7| Test 1 test:test_group3 due:2016-12-06
due: in a day
=============
| 8| Test 2 test:test_group3 due:2016-12-07
"""
)
def
test_group4
(
self
):
todolist
=
load_file_to_todolist
(
"test/data/ListCommandGroupTest.txt"
)
command
=
ListCommand
([
"-g"
,
"t"
,
"test:test_group4"
],
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
todolist
.
dirty
)
self
.
assertEqual
(
self
.
output
,
"""
\
t: today
========
| 9| Test 1 test:test_group4 test:test_group5 t:2016-12-06
"""
)
def
test_group5
(
self
):
todolist
=
load_file_to_todolist
(
"test/data/ListCommandGroupTest.txt"
)
command
=
ListCommand
([
"-x"
,
"-g"
,
"t"
,
"test:test_group5"
],
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
todolist
.
dirty
)
self
.
assertEqual
(
self
.
output
,
"""
\
t: today
========
| 9| Test 1 test:test_group4 test:test_group5 t:2016-12-06
t: in a day
===========
| 10| Test 2 test:test_group4 test:test_group5 t:2016-12-07
"""
)
def
test_group6
(
self
):
todolist
=
load_file_to_todolist
(
"test/data/ListCommandGroupTest.txt"
)
command
=
ListCommand
([
"-x"
,
"-g"
,
"fake"
,
"test_group6"
],
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
todolist
.
dirty
)
self
.
assertEqual
(
self
.
output
,
"""
\
fake: No value
==============
| 11| Group by non-existing tag test:test_group6
"""
)
def
test_group7
(
self
):
todolist
=
load_file_to_todolist
(
"test/data/ListCommandGroupTest.txt"
)
command
=
ListCommand
([
"-x"
,
"-g"
,
"desc:project"
,
"test_group7"
],
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
todolist
.
dirty
)
self
.
assertEqual
(
self
.
output
,
"""
\
Project: B
==========
| 13| Sort descending +B test:test_group7
Project: A
==========
| 12| Sort descending +A test:test_group7
"""
)
def
test_group8
(
self
):
todolist
=
load_file_to_todolist
(
"test/data/ListCommandGroupTest.txt"
)
command
=
ListCommand
([
"-x"
,
"-g"
,
"project,desc:context"
,
"test_group8"
],
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
todolist
.
dirty
)
self
.
assertEqual
(
self
.
output
,
"""
\
Project: A, Context: B
======================
| 15| Inner sort 2 +A @B test:test_group8
Project: A, Context: A
======================
| 14| Inner sort 1 +A @A test:test_group8
Project: B, Context: B
======================
| 17| Inner sort 4 +B @B test:test_group8
Project: B, Context: A
======================
| 16| Inner sort 3 +B @A test:test_group8
"""
)
def
test_group9
(
self
):
todolist
=
load_file_to_todolist
(
"test/data/ListCommandGroupTest.txt"
)
command
=
ListCommand
([
"-x"
,
"-g"
,
"project"
,
"-s"
,
"desc:text"
,
"test_group9"
],
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
todolist
.
dirty
)
self
.
assertEqual
(
self
.
output
,
"""
\
Project: A
==========
| 19| Inner sort 2 +A test:test_group9
| 18| Inner sort 1 +A test:test_group9
"""
)
if
__name__
==
'__main__'
:
unittest
.
main
()
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