~nmu-sscheel/gtg/rework-task-editor

« back to all changes in this revision

Viewing changes to GTG/tests/test_tool_tags.py

  • Committer: Bertrand Rousseau
  • Date: 2012-05-09 22:33:25 UTC
  • mfrom: (1178 trunk)
  • mto: This revision was merged to the branch mainline in revision 1179.
  • Revision ID: bertrand.rousseau@gmail.com-20120509223325-a53d8nwo0x9g93bc
Merge nimit branch and trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
# -----------------------------------------------------------------------------
19
 
 
20
 
'''
21
 
Tests for the tags utilities
22
 
'''
 
19
""" Tests for the tags utilities """
23
20
 
24
21
import unittest
25
22
 
26
 
from GTG.tools.tags import *
27
 
 
28
 
 
29
 
 
30
 
class TestTagsUtils(unittest.TestCase):
31
 
    '''
32
 
    Tests for the tags utilities
33
 
    '''
34
 
    
 
23
from GTG.tools.tags import extract_tags_from_text
 
24
from GTG.tools.tags import parse_tag_list
 
25
 
 
26
 
 
27
class TestToolTags(unittest.TestCase):
 
28
    """ Tests for the tags utilities """
 
29
 
35
30
    def test_extract_tags_from_text(self):
36
 
        '''
37
 
        Test for extracting tags from a string
38
 
        '''
39
 
        tests = (\
 
31
        """ Test for extracting tags from a string """
 
32
        tests = (
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)
49
42
 
50
 
 
51
 
 
 
43
    def test_parse_tag_list(self):
 
44
        """ Test parsing tag list"""
 
45
        ptl = parse_tag_list
 
46
 
 
47
        self.assertEqual(ptl("tag"), [("@tag", True)])
 
48
        self.assertEqual(ptl("@tag"), [("@tag", True)])
 
49
 
 
50
        self.assertEqual(ptl("!tag"), [("@tag", False)])
 
51
        self.assertEqual(ptl("!@tag"), [("@tag", False)])
 
52
 
 
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)])
 
61
 
 
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)])
 
70
 
 
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)])
52
79
 
53
80
 
54
81
def test_suite():
55
 
    return unittest.TestLoader().loadTestsFromTestCase(TestTagsUtils)
56
 
 
 
82
    return unittest.TestLoader().loadTestsFromTestCase(TestToolTags)