Exemplo n.º 1
0
    def testPageInvalidChars(self):
        """ request: normalize pagename: remove invalid unicode chars

        Assume the default setting
        """
        test = '\u0000\u202a\u202b\u202c\u202d\u202e'
        expected = ''
        result = wikiutil.normalize_pagename(test, app.cfg)
        assert result == expected
Exemplo n.º 2
0
 def testNormalizeSlashes(self):
     """ request: normalize pagename: normalize slashes """
     cases = (
         ('/////', ''),
         ('/a', 'a'),
         ('a/', 'a'),
         ('a/////b/////c', 'a/b/c'),
         ('a b/////c d/////e f', 'a b/c d/e f'),
     )
     for test, expected in cases:
         result = wikiutil.normalize_pagename(test, app.cfg)
         assert result == expected
Exemplo n.º 3
0
 def testNormalizeWhitespace(self):
     """ request: normalize pagename: normalize whitespace """
     cases = (
         ('         ', ''),
         ('    a', 'a'),
         ('a    ', 'a'),
         ('a     b     c', 'a b c'),
         ('a   b  /  c    d  /  e   f', 'a b/c d/e f'),
         # All 30 unicode spaces
         (CHARS_SPACES, ''),
     )
     for test, expected in cases:
         result = wikiutil.normalize_pagename(test, app.cfg)
         assert result == expected
Exemplo n.º 4
0
    def testNormalizeGroupName(self):
        """ request: normalize itemname: restrict groups to alpha numeric Unicode

        Spaces should normalize after invalid chars removed!
        """
        cases = (
            # current acl chars
            ('Name,:Group', 'NameGroup'),
            # remove than normalize spaces
            ('Name ! @ # $ % ^ & * ( ) + Group', 'Name Group'),
        )
        for test, expected in cases:
            # validate we are testing valid group names
            if wikiutil.isGroupItem(test):
                result = wikiutil.normalize_pagename(test, app.cfg)
                assert result == expected
Exemplo n.º 5
0
    def testUnderscoreTestCase(self):
        """ request: normalize pagename: underscore convert to spaces and normalized

        Underscores should convert to spaces, then spaces should be
        normalized, order is important!
        """
        cases = (
            ('         ', ''),
            ('  a', 'a'),
            ('a  ', 'a'),
            ('a  b  c', 'a b c'),
            ('a  b  /  c  d  /  e  f', 'a b/c d/e f'),
        )
        for test, expected in cases:
            result = wikiutil.normalize_pagename(test, app.cfg)
            assert result == expected