# Path: ldaptor/protocols/ldap/ldifdelta.py
# WAIT_FOR_CHANGETYPE = 'WAIT_FOR_CHANGETYPE'
# WAIT_FOR_MOD_SPEC = 'WAIT_FOR_MOD_SPEC'
# IN_MOD_SPEC = 'IN_MOD_SPEC'
# IN_ADD_ENTRY = 'IN_ADD_ENTRY'
# IN_DELETE = 'IN_DELETE'
#     MOD_SPEC_TO_DELTA = {
#         'add': delta.Add,
#         'delete': delta.Delete,
#         'replace': delta.Replace,
#         }
# class LDIFDeltaMissingChangeTypeError(ldifprotocol.LDIFParseError):
# class LDIFDeltaUnknownModificationError(ldifprotocol.LDIFParseError):
# class LDIFDeltaModificationMissingEndDashError(ldifprotocol.LDIFParseError):
# class LDIFDeltaModificationDifferentAttributeTypeError(ldifprotocol.LDIFParseError):
# class LDIFDeltaAddMissingAttributesError(ldifprotocol.LDIFParseError):
# class LDIFDeltaDeleteHasJunkAfterChangeTypeError(ldifprotocol.LDIFParseError):
# class LDIFDelta(ldifprotocol.LDIF):
#     def state_WAIT_FOR_DN(self, line):
#     def state_WAIT_FOR_CHANGETYPE(self, line):
#     def state_WAIT_FOR_MOD_SPEC(self, line):
#     def state_IN_MOD_SPEC(self, line):
#     def state_IN_ADD_ENTRY(self, line):
#     def state_IN_DELETE(self, line):
# def fromLDIFFile(f):
# 
# Path: ldaptor/delta.py
# class Modification(attributeset.LDAPAttributeSet):
# class Add(Modification):
# class Delete(Modification):
# class Replace(Modification):
# class Operation(object):
# class ModifyOp(Operation):
# class AddOp(Operation):
# class DeleteOp(Operation):
#     def patch(self, entry):
#     def asLDAP(self):
#     def __eq__(self, other):
#     def patch(self, entry):
#     def asLDIF(self):
#     def patch(self, entry):
#     def asLDIF(self):
#     def patch(self, entry):
#     def asLDIF(self):
#     def patch(self, root):
#     def __init__(self, dn, modifications=[]):
#     def asLDIF(self):
#     def asLDAP(self):
#     def _getClassFromOp(class_, op):
#     def fromLDAP(class_, request):
#     def patch(self, root):
#         def gotEntry(entry, modifications):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __init__(self, entry):
#     def asLDIF(self):
#     def patch(self, root):
#         def gotParent(parent, entry):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __init__(self, dn):
#     def asLDIF(self):
#     def patch(self, root):
#         def gotEntry(entry):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     _LDAP_OP = None
#     _LDAP_OP = 0
#     _LDAP_OP = 1
#     _LDAP_OP = 2
# 
# Path: ldaptor/entry.py
# def sshaDigest(passphrase, salt=None):
#     def __init__(self, dn, attributes={}):
#     def buildAttributeSet(self, key, values):
#     def __getitem__(self, key):
#     def get(self, key, default=None):
#     def has_key(self, key):
#     def __contains__(self, key):
#     def keys(self):
#     def items(self):
#     def __str__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __len__(self):
#     def __nonzero__(self):
#     def __repr__(self):
#     def diff(self, other):
#     def bind(self, password):
#     def _bind(self, password):
#     def hasMember(self, dn):
#     def __hash__(self):
#     def __setitem__(self, key, value):
#     def __delitem__(self, key):
#     def undo(self):
#     def commit(self):
#     def move(self, newDN):
#     def delete(self):
#     def setPassword(self, newPasswd, salt=None):
# class BaseLDAPEntry(object):
# class EditableLDAPEntry(BaseLDAPEntry):


from twisted.trial import unittest
from ldaptor.protocols.ldap import ldifdelta
from ldaptor import delta, entry
class TestLDIFDeltaParsing(unittest.TestCase):
    def testModification_empty(self):
        proto = LDIFDeltaDriver()
        proto.dataReceived("""\
version: 1
dn: cn=foo,dc=example,dc=com
changetype: modify

""")
        proto.connectionLost()
        self.assertEqual(proto.listOfCompleted,
                         [
            delta.ModifyOp(dn='cn=foo,dc=example,dc=com'),
            ])

    def testModification_oneAdd(self):
        proto = LDIFDeltaDriver()
        proto.dataReceived("""\
version: 1
dn: cn=foo,dc=example,dc=com
changetype: modify
add: foo
foo: bar
-

""")
        proto.connectionLost()
        self.assertEqual(
            proto.listOfCompleted,
            [delta.ModifyOp(dn='cn=foo,dc=example,dc=com',

# Path: ldaptor/protocols/ldap/ldifdelta.py
# WAIT_FOR_CHANGETYPE = 'WAIT_FOR_CHANGETYPE'
# WAIT_FOR_MOD_SPEC = 'WAIT_FOR_MOD_SPEC'
# IN_MOD_SPEC = 'IN_MOD_SPEC'
# IN_ADD_ENTRY = 'IN_ADD_ENTRY'
# IN_DELETE = 'IN_DELETE'
#     MOD_SPEC_TO_DELTA = {
#         'add': delta.Add,
#         'delete': delta.Delete,
#         'replace': delta.Replace,
#         }
# class LDIFDeltaMissingChangeTypeError(ldifprotocol.LDIFParseError):
# class LDIFDeltaUnknownModificationError(ldifprotocol.LDIFParseError):
# class LDIFDeltaModificationMissingEndDashError(ldifprotocol.LDIFParseError):
# class LDIFDeltaModificationDifferentAttributeTypeError(ldifprotocol.LDIFParseError):
# class LDIFDeltaAddMissingAttributesError(ldifprotocol.LDIFParseError):
# class LDIFDeltaDeleteHasJunkAfterChangeTypeError(ldifprotocol.LDIFParseError):
# class LDIFDelta(ldifprotocol.LDIF):
#     def state_WAIT_FOR_DN(self, line):
#     def state_WAIT_FOR_CHANGETYPE(self, line):
#     def state_WAIT_FOR_MOD_SPEC(self, line):
#     def state_IN_MOD_SPEC(self, line):
#     def state_IN_ADD_ENTRY(self, line):
#     def state_IN_DELETE(self, line):
# def fromLDIFFile(f):
# 
# Path: ldaptor/delta.py
# class Modification(attributeset.LDAPAttributeSet):
# class Add(Modification):
# class Delete(Modification):
# class Replace(Modification):
# class Operation(object):
# class ModifyOp(Operation):
# class AddOp(Operation):
# class DeleteOp(Operation):
#     def patch(self, entry):
#     def asLDAP(self):
#     def __eq__(self, other):
#     def patch(self, entry):
#     def asLDIF(self):
#     def patch(self, entry):
#     def asLDIF(self):
#     def patch(self, entry):
#     def asLDIF(self):
#     def patch(self, root):
#     def __init__(self, dn, modifications=[]):
#     def asLDIF(self):
#     def asLDAP(self):
#     def _getClassFromOp(class_, op):
#     def fromLDAP(class_, request):
#     def patch(self, root):
#         def gotEntry(entry, modifications):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __init__(self, entry):
#     def asLDIF(self):
#     def patch(self, root):
#         def gotParent(parent, entry):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __init__(self, dn):
#     def asLDIF(self):
#     def patch(self, root):
#         def gotEntry(entry):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     _LDAP_OP = None
#     _LDAP_OP = 0
#     _LDAP_OP = 1
#     _LDAP_OP = 2
# 
# Path: ldaptor/entry.py
# def sshaDigest(passphrase, salt=None):
#     def __init__(self, dn, attributes={}):
#     def buildAttributeSet(self, key, values):
#     def __getitem__(self, key):
#     def get(self, key, default=None):
#     def has_key(self, key):
#     def __contains__(self, key):
#     def keys(self):
#     def items(self):
#     def __str__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __len__(self):
#     def __nonzero__(self):
#     def __repr__(self):
#     def diff(self, other):
#     def bind(self, password):
#     def _bind(self, password):
#     def hasMember(self, dn):
#     def __hash__(self):
#     def __setitem__(self, key, value):
#     def __delitem__(self, key):
#     def undo(self):
#     def commit(self):
#     def move(self, newDN):
#     def delete(self):
#     def setPassword(self, newPasswd, salt=None):
# class BaseLDAPEntry(object):
# class EditableLDAPEntry(BaseLDAPEntry):


# Path: ldaptor/test/test_ldifdelta.py
from twisted.trial import unittest
from ldaptor.protocols.ldap import ldifdelta
from ldaptor import delta, entry

class TestLDIFDeltaParsing(unittest.TestCase):
    def testModification_empty(self):
        proto = LDIFDeltaDriver()
        proto.dataReceived("""\
version: 1
dn: cn=foo,dc=example,dc=com
changetype: modify

""")
        proto.connectionLost()
        self.assertEqual(proto.listOfCompleted,
                         [
            delta.ModifyOp(dn='cn=foo,dc=example,dc=com'),
            ])

    def testModification_oneAdd(self):
        proto = LDIFDeltaDriver()
        proto.dataReceived("""\
version: 1
dn: cn=foo,dc=example,dc=com
changetype: modify
add: foo
foo: bar
-

""")
        proto.connectionLost()
        self.assertEqual(
            proto.listOfCompleted,
            [delta.ModifyOp(dn='cn=foo,dc=example,dc=com',

                            modifications=[delta.Add('foo', ['bar']),