Skip to content

Commit

Permalink
class TestChangeRecords
Browse files Browse the repository at this point in the history
  • Loading branch information
stroeder committed Jul 17, 2016
1 parent 9ab2919 commit 0601713
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions Tests/t_ldif.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
See http://www.python-ldap.org/ for details.
$Id: t_ldif.py,v 1.16 2016/02/29 22:44:42 stroeder Exp $
$Id: t_ldif.py,v 1.17 2016/07/17 16:25:46 stroeder Exp $
"""

# from Python's standard lib
Expand Down Expand Up @@ -54,7 +54,7 @@ def unparse_records(records):
return ldif_file.getvalue()


class TestEntryRecords(unittest.TestCase):
class TestLDIFParser(unittest.TestCase):
"""
Various LDIF test cases
"""
Expand Down Expand Up @@ -87,6 +87,12 @@ def check_records(
self.assertEqual(parsed_records, records)
self.assertEqual(parsed_records2, records)


class TestEntryRecords(TestLDIFParser):
"""
Various LDIF test cases
"""

def test_empty(self):
self.check_records(
"""
Expand Down Expand Up @@ -391,5 +397,49 @@ def test_multiple_empty_lines(self):
)


class TestChangeRecords(TestLDIFParser):
"""
Various LDIF test cases
"""

def test_empty(self):
self.check_records(
"""
version: 1
""",
[],
record_type='change',
)

def test_simple(self):
self.check_records(
"""
version: 1
dn: cn=x,cn=y,cn=z
changetype: modify
replace: attrib
attrib: value
attrib: value2
-
add: attrib2
attrib2: value
attrib2: value2
-
delete: attrib3
attrib3: value
-
delete: attrib4
-
""",
[
(ldif.MOD_OP_INTEGER['replace'], 'attrib', [b'value', b'value2']),
(ldif.MOD_OP_INTEGER['add'], 'attrib2', [b'value', b'value2']),
(ldif.MOD_OP_INTEGER['delete'], 'attrib3', [b'value']),
(ldif.MOD_OP_INTEGER['delete'], 'attrib4', None),
],
record_type='change',
)

if __name__ == '__main__':
unittest.main()

0 comments on commit 0601713

Please sign in to comment.