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
0b1d1139
Commit
0b1d1139
authored
Jun 12, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add method to mark a todo as completed.
parent
391a7283
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
0 deletions
+46
-0
TodoBase.py
TodoBase.py
+13
-0
test/TodoBaseTest.py
test/TodoBaseTest.py
+33
-0
No files found.
TodoBase.py
View file @
0b1d1139
...
...
@@ -2,6 +2,7 @@
This module contains the class that represents a single todo item.
"""
import
datetime
import
re
import
TodoParser
...
...
@@ -135,6 +136,18 @@ class TodoBase(object):
""" Returns True iff this todo has been completed. """
return self.fields['
completed
']
def set_completed(self):
"""
Marks the todo as complete.
Sets the completed flag and sets the completion date to today.
"""
self.fields['
completed
'] = True
today = datetime.date.today()
self.fields['
completionDate
'] = today
self.src = re.sub(r'
^
(
\
([
A
-
Z
]
\
)
)
?
',
\
'
x
' + today.isoformat() + '
', self.src)
def __print__(self):
""" A printer for the todo item. """
print self.src + "
\
n
"
test/TodoBaseTest.py
View file @
0b1d1139
""" Tests for the TodoBase class. """
import
datetime
import
re
import
unittest
...
...
@@ -144,5 +145,37 @@ class TodoBaseTester(unittest.TestCase):
self
.
assertFalse
(
todo
.
is_completed
())
def
test_set_complete1
(
self
):
todo
=
TodoBase
.
TodoBase
(
"(A) Foo"
)
todo
.
set_completed
()
today
=
datetime
.
date
.
today
().
isoformat
()
self
.
assertTrue
(
re
.
match
(
'^x '
+
today
+
' Foo'
,
todo
.
src
))
def
test_set_complete2
(
self
):
todo
=
TodoBase
.
TodoBase
(
"2014-06-12 Foo"
)
todo
.
set_completed
()
today
=
datetime
.
date
.
today
().
isoformat
()
self
.
assertTrue
(
re
.
match
(
'^x '
+
today
+
' 2014-06-12 Foo'
,
todo
.
src
))
def
test_set_complete3
(
self
):
todo
=
TodoBase
.
TodoBase
(
"Foo"
)
todo
.
set_completed
()
today
=
datetime
.
date
.
today
().
isoformat
()
self
.
assertTrue
(
re
.
match
(
'^x '
+
today
+
' Foo'
,
todo
.
src
))
def
test_set_complete4
(
self
):
todo
=
TodoBase
.
TodoBase
(
"(A) 2014-06-12 Foo"
)
todo
.
set_completed
()
today
=
datetime
.
date
.
today
().
isoformat
()
self
.
assertTrue
(
re
.
match
(
'^x '
+
today
+
' 2014-06-12 Foo'
,
todo
.
src
))
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