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
b53b24af
Commit
b53b24af
authored
Jun 13, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for the TodoList class.
parent
d58811de
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
0 deletions
+85
-0
test/TodoListTest.py
test/TodoListTest.py
+80
-0
test/TodoListTest.txt
test/TodoListTest.txt
+5
-0
No files found.
test/TodoListTest.py
0 → 100644
View file @
b53b24af
""" Tests for the TodoList class. """
import
datetime
import
unittest
import
TodoFile
import
TodoList
class
TodoListTester
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
todofile
=
TodoFile
.
TodoFile
(
'TodoListTest.txt'
)
self
.
todolist
=
TodoList
.
TodoList
(
self
.
todofile
.
read
())
def
test_contexts
(
self
):
self
.
assertEquals
(
set
([
'Context1'
,
'Context2'
]),
\
self
.
todolist
.
contexts
())
def
test_projects
(
self
):
self
.
assertEquals
(
set
([
'Project1'
,
'Project2'
]),
\
self
.
todolist
.
projects
())
def
test_add
(
self
):
text
=
"(C) Adding a new task @Context3 +Project3"
self
.
todolist
.
add
(
text
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
6
).
src
,
text
)
self
.
assertEquals
(
set
([
'Project1'
,
'Project2'
,
'Project3'
]),
\
self
.
todolist
.
projects
())
self
.
assertEquals
(
set
([
'Context1'
,
'Context2'
,
'Context3'
]),
\
self
.
todolist
.
contexts
())
def
test_delete1
(
self
):
count
=
self
.
todolist
.
count
()
self
.
todolist
.
delete
(
2
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
2
).
src
,
\
"(C) Baz @Context1 +Project1 key:value"
)
self
.
assertEquals
(
self
.
todolist
.
count
(),
count
-
1
)
def
test_delete2
(
self
):
count
=
self
.
todolist
.
count
()
self
.
todolist
.
delete
(
count
+
1
)
self
.
assertEquals
(
self
.
todolist
.
count
(),
count
)
def
test_append1
(
self
):
self
.
todolist
.
append
(
3
,
"@Context3"
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
3
).
source
(),
\
"(C) Baz @Context1 +Project1 key:value @Context3"
)
self
.
assertEquals
(
set
([
'Context1'
,
'Context2'
,
'Context3'
]),
\
self
.
todolist
.
contexts
())
def
test_append2
(
self
):
text
=
self
.
todolist
.
todo
(
3
).
text
()
self
.
todolist
.
append
(
3
,
"foo:bar"
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
3
).
text
(),
text
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
3
).
source
(),
\
"(C) Baz @Context1 +Project1 key:value foo:bar"
)
def
test_append3
(
self
):
text
=
self
.
todolist
.
todo
(
3
).
text
()
self
.
todolist
.
append
(
3
,
''
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
3
).
text
(),
text
)
def
test_todo
(
self
):
count
=
self
.
todolist
.
count
()
todo
=
self
.
todolist
.
todo
(
count
+
100
)
self
.
assertEquals
(
todo
,
None
)
def
test_completed
(
self
):
self
.
todolist
.
todo
(
1
).
set_completed
()
today
=
datetime
.
date
.
today
().
isoformat
()
self
.
assertTrue
(
self
.
todolist
.
todo
(
1
).
is_completed
())
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
source
(),
\
"x "
+
today
+
" Foo @Context1 Not@Context +Project1 Not+Project"
)
test/TodoListTest.txt
0 → 100644
View file @
b53b24af
(C) Foo @Context1 Not@Context +Project1 Not+Project
(D) Bar @Context2 +Project2
(C) Baz @Context1 +Project1 key:value
(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