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
c460518f
Commit
c460518f
authored
Jun 09, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test code for the base Todo class.
parent
722df420
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
0 deletions
+105
-0
test/TodoBase.py
test/TodoBase.py
+105
-0
No files found.
test/TodoBase.py
0 → 100644
View file @
c460518f
import
re
import
unittest
import
TodoBase
class
TodoBaseTester
(
unittest
.
TestCase
):
def
test_parse_tag
(
self
):
todo
=
TodoBase
.
TodoBase
(
"(C) Test foo:bar foo:baz foo_:baz_ blah:zah:haz"
)
self
.
assertTrue
(
todo
.
has_tag
(
'foo'
))
self
.
assertTrue
(
todo
.
has_tag
(
'foo_'
))
self
.
assertTrue
(
todo
.
has_tag
(
'foo'
,
'bar'
))
self
.
assertTrue
(
todo
.
has_tag
(
'foo'
,
'baz'
))
self
.
assertTrue
(
todo
.
has_tag
(
'blah'
))
self
.
assertTrue
(
todo
.
has_tag
(
'blah'
,
'zah:haz'
))
def
test_add_tag
(
self
):
todo
=
TodoBase
.
TodoBase
(
"(C) Foo"
)
todo
.
set_tag
(
'foo'
,
'bar'
)
self
.
assertTrue
(
todo
.
has_tag
(
'foo'
))
self
.
assertTrue
(
todo
.
has_tag
(
'foo'
,
'bar'
))
self
.
assertFalse
(
todo
.
has_tag
(
'foo'
,
'baz'
))
self
.
assertFalse
(
todo
.
has_tag
(
'bar'
))
self
.
assertTrue
(
re
.
search
(
r'\bfoo:bar\b'
,
todo
.
src
))
def
test_set_tag
(
self
):
todo
=
TodoBase
.
TodoBase
(
"(C) Foo foo:bar"
)
todo
.
set_tag
(
'foo'
,
'baz'
)
self
.
assertTrue
(
todo
.
has_tag
(
'foo'
))
self
.
assertTrue
(
todo
.
has_tag
(
'foo'
,
'baz'
))
self
.
assertFalse
(
todo
.
has_tag
(
'foo'
,
'bar'
))
self
.
assertTrue
(
re
.
search
(
r'\bfoo:baz\b'
,
todo
.
src
))
self
.
assertFalse
(
re
.
search
(
r'\bfoo:bar\b'
,
todo
.
src
))
def
test_set_tag_empty_value
(
self
):
todo
=
TodoBase
.
TodoBase
(
"(C) Foo foo:bar foo:baz"
)
todo
.
set_tag
(
'foo'
)
self
.
assertFalse
(
todo
.
has_tag
(
'foo'
))
self
.
assertFalse
(
re
.
search
(
r'\bfoo:'
,
todo
.
src
))
def
test_remove_all
(
self
):
todo
=
TodoBase
.
TodoBase
(
"(C) Foo foo:bar foo:baz foo:"
)
todo
.
remove_tag
(
'foo'
)
self
.
assertFalse
(
todo
.
has_tag
(
'foo'
))
self
.
assertFalse
(
re
.
search
(
r'\bfoo:(bar|baz)\b'
,
todo
.
src
))
self
.
assertTrue
(
re
.
search
(
r'foo:'
,
todo
.
src
))
def
test_remove_specific_tag_value
(
self
):
todo
=
TodoBase
.
TodoBase
(
"(C) Foo kungfoo:bar foo:bar foo:barz"
)
todo
.
remove_tag
(
'foo'
,
'bar'
)
self
.
assertTrue
(
todo
.
has_tag
(
'foo'
))
self
.
assertTrue
(
todo
.
has_tag
(
'kungfoo'
,
'bar'
))
self
.
assertTrue
(
todo
.
has_tag
(
'foo'
,
'barz'
))
self
.
assertFalse
(
todo
.
has_tag
(
'foo'
,
'bar'
))
self
.
assertTrue
(
re
.
search
(
r'\bkungfoo:bar\b'
,
todo
.
src
))
self
.
assertTrue
(
re
.
search
(
r'\bfoo:barz\b'
,
todo
.
src
))
self
.
assertFalse
(
re
.
search
(
r'\bfoo:bar\b'
,
todo
.
src
))
def
test_set_priority1
(
self
):
todo
=
TodoBase
.
TodoBase
(
"(A) Foo"
)
todo
.
set_priority
(
'B'
)
self
.
assertEquals
(
todo
.
priority
(),
'B'
)
self
.
assertTrue
(
re
.
match
(
r'^\
(B
\) Foo$'
,
todo
.
src
))
def
test_set_priority2
(
self
):
todo
=
TodoBase
.
TodoBase
(
"Foo"
)
todo
.
set_priority
(
'B'
)
self
.
assertEquals
(
todo
.
priority
(),
'B'
)
self
.
assertTrue
(
re
.
match
(
r'^\
(B
\) Foo$'
,
todo
.
src
))
def
test_set_priority3
(
self
):
todo
=
TodoBase
.
TodoBase
(
"(A) Foo"
)
todo
.
set_priority
(
'AB'
)
self
.
assertEquals
(
todo
.
priority
(),
'A'
)
self
.
assertTrue
(
re
.
match
(
r'^\
(A
\) Foo$'
,
todo
.
src
))
def
test_set_priority4
(
self
):
todo
=
TodoBase
.
TodoBase
(
"(A)Foo"
)
self
.
assertNotEqual
(
todo
.
priority
(),
'A'
)
todo
.
set_priority
(
'B'
)
self
.
assertEquals
(
todo
.
priority
(),
'B'
)
self
.
assertTrue
(
re
.
match
(
r'^\
(B
\) \
(A
\)Foo$'
,
todo
.
src
))
def
test_set_priority5
(
self
):
todo
=
TodoBase
.
TodoBase
(
"(A) Foo"
)
todo
.
set_priority
(
None
)
self
.
assertEquals
(
todo
.
priority
(),
None
)
self
.
assertTrue
(
re
.
match
(
r'^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