16
16
# You should have received a copy of the GNU General Public License along with
17
17
# this program. If not, see <http://www.gnu.org/licenses/>.
18
18
# -----------------------------------------------------------------------------
21
Tests for the tags utilities
19
""" Tests for the tags utilities """
26
from GTG.tools.tags import *
30
class TestTagsUtils(unittest.TestCase):
32
Tests for the tags utilities
23
from GTG.tools.tags import extract_tags_from_text
24
from GTG.tools.tags import parse_tag_list
27
class TestToolTags(unittest.TestCase):
28
""" Tests for the tags utilities """
35
30
def test_extract_tags_from_text(self):
37
Test for extracting tags from a string
31
""" Test for extracting tags from a string """
40
33
("@mamma mia", ["@mamma"]),
41
34
("vive le @roy", ["@roy"]),
42
35
("hey @mr. jack!", ["@mr"]),
47
40
for text, tags in tests:
48
41
self.assertEqual(extract_tags_from_text(text), tags)
43
def test_parse_tag_list(self):
44
""" Test parsing tag list"""
47
self.assertEqual(ptl("tag"), [("@tag", True)])
48
self.assertEqual(ptl("@tag"), [("@tag", True)])
50
self.assertEqual(ptl("!tag"), [("@tag", False)])
51
self.assertEqual(ptl("!@tag"), [("@tag", False)])
53
self.assertEqual(ptl("a b c"),
54
[("@a", True), ("@b", True), ("@c", True)])
55
self.assertEqual(ptl("a @b c"),
56
[("@a", True), ("@b", True), ("@c", True)])
57
self.assertEqual(ptl("@a b @c"),
58
[("@a", True), ("@b", True), ("@c", True)])
59
self.assertEqual(ptl("@a @b @c"),
60
[("@a", True), ("@b", True), ("@c", True)])
62
self.assertEqual(ptl("!a !b !c"),
63
[("@a", False), ("@b", False), ("@c", False)])
64
self.assertEqual(ptl("!a !@b !c"),
65
[("@a", False), ("@b", False), ("@c", False)])
66
self.assertEqual(ptl("!@a !b !@c"),
67
[("@a", False), ("@b", False), ("@c", False)])
68
self.assertEqual(ptl("!@a !@b !@c"),
69
[("@a", False), ("@b", False), ("@c", False)])
71
self.assertEqual(ptl("add !remove"),
72
[("@add", True), ("@remove", False)])
73
self.assertEqual(ptl("@add !@remove"),
74
[("@add", True), ("@remove", False)])
75
self.assertEqual(ptl("!remove add"),
76
[("@remove", False), ("@add", True)])
77
self.assertEqual(ptl("!@remove @add"),
78
[("@remove", False), ("@add", True)])
55
return unittest.TestLoader().loadTestsFromTestCase(TestTagsUtils)
82
return unittest.TestLoader().loadTestsFromTestCase(TestToolTags)