Skip to content

Commit

Permalink
test escape_filter_chars() with all possible escape_mode values
Browse files Browse the repository at this point in the history
  • Loading branch information
stroeder committed Jul 24, 2016
1 parent 82e1985 commit d4ae026
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions Tests/t_ldap_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,49 @@ class TestDN(unittest.TestCase):
test ldap.functions
"""

def test_escape_filter_chars(self):
def test_escape_filter_chars_mode0(self):
"""
test function is_dn()
test function escape_filter_chars() with escape_mode=0
"""
self.assertEquals(escape_filter_chars(r'foobar'), 'foobar')
self.assertEquals(escape_filter_chars(r'foo\bar'), r'foo\5cbar')
self.assertEquals(
escape_filter_chars(r'foobar'),
'foobar'
)
self.assertEquals(
escape_filter_chars(r'foo\bar'),
r'foo\5cbar'
)
self.assertEquals(
escape_filter_chars(
r'foo\bar',
escape_mode=0
),
r'foo\5cbar'
)

def test_escape_filter_chars_mode1(self):
"""
test function escape_filter_chars() with escape_mode=1
"""
self.assertEquals(
escape_filter_chars(
'\xc3\xa4\xc3\xb6\xc3\xbc\xc3\x84\xc3\x96\xc3\x9c\xc3\x9f',
escape_mode=1
),
r'\c3\a4\c3\b6\c3\bc\c3\84\c3\96\c3\9c\c3\9f'
)

def test_escape_filter_chars_mode2(self):
"""
test function escape_filter_chars() with escape_mode=2
"""
self.assertEquals(
escape_filter_chars(
'foobar',
escape_mode=2
),
r'\66\6f\6f\62\61\72'
)


if __name__ == '__main__':
Expand Down

0 comments on commit d4ae026

Please sign in to comment.