コード例 #1
0
def test_build_dn_appends_dn():
    mock_ldif_writer = MockLdifWriter()
    eq_([], mock_ldif_writer.called_with)
    dn_ldif = BuildDnLdifWriter("dc=yup", mock_ldif_writer)
    eq_([], mock_ldif_writer.called_with)
    dn_ldif.unparse("cn=test", dict(foo="bar"))
    eq_([("cn=test,dc=yup", dict(foo="bar"))], mock_ldif_writer.called_with)
コード例 #2
0
def test_build_dn_appends_dn():
    mock_ldif_writer = MockLdifWriter()
    eq_([], mock_ldif_writer.called_with)
    dn_ldif = BuildDnLdifWriter('dc=yup', mock_ldif_writer)
    eq_([], mock_ldif_writer.called_with)
    dn_ldif.unparse('cn=test', dict(foo='bar'))
    eq_([('cn=test,dc=yup', dict(foo='bar'))],
         mock_ldif_writer.called_with)
コード例 #3
0
def test_extend_nests():
    mock_ldif_writer = MockLdifWriter()
    eq_([], mock_ldif_writer.called_with)
    dn_ldif = BuildDnLdifWriter("dc=yup", mock_ldif_writer)
    eq_([], mock_ldif_writer.called_with)
    dn2_ldif = dn_ldif.extend("dc=more")
    eq_([], mock_ldif_writer.called_with)
    dn2_ldif.unparse("cn=test", dict(foo="bar"))
    eq_([("cn=test,dc=more,dc=yup", dict(foo="bar"))], mock_ldif_writer.called_with)
コード例 #4
0
def test_build_dn_can_nest():
    mock_ldif_writer = MockLdifWriter()
    eq_([], mock_ldif_writer.called_with)
    dn_ldif = BuildDnLdifWriter("dc=yup", mock_ldif_writer)
    eq_([], mock_ldif_writer.called_with)
    dn2_ldif = BuildDnLdifWriter("dc=more", dn_ldif)
    eq_([], mock_ldif_writer.called_with)
    dn2_ldif.unparse("cn=test", dict(foo="bar"))
    eq_([("cn=test,dc=more,dc=yup", dict(foo="bar"))], mock_ldif_writer.called_with)
コード例 #5
0
def test_full_dn():
    mock_ldif_writer = MockLdifWriter()
    eq_(None, full_dn(mock_ldif_writer))
    bl1 = BuildDnLdifWriter("dc=yup", mock_ldif_writer)
    eq_("dc=yup", bl1.full_dn())
    eq_("dc=yup", full_dn(bl1))
    bl2 = BuildDnLdifWriter("ou=nope", bl1)
    eq_("ou=nope,dc=yup", bl2.full_dn())
    eq_("ou=nope,dc=yup", full_dn(bl2))
コード例 #6
0
def test_extend_nests():
    mock_ldif_writer = MockLdifWriter()
    eq_([], mock_ldif_writer.called_with)
    dn_ldif = BuildDnLdifWriter('dc=yup', mock_ldif_writer)
    eq_([], mock_ldif_writer.called_with)
    dn2_ldif = dn_ldif.extend('dc=more')
    eq_([], mock_ldif_writer.called_with)
    dn2_ldif.unparse('cn=test', dict(foo='bar'))
    eq_([('cn=test,dc=more,dc=yup', dict(foo='bar'))],
         mock_ldif_writer.called_with)
コード例 #7
0
def test_build_dn_can_nest():
    mock_ldif_writer = MockLdifWriter()
    eq_([], mock_ldif_writer.called_with)
    dn_ldif = BuildDnLdifWriter('dc=yup', mock_ldif_writer)
    eq_([], mock_ldif_writer.called_with)
    dn2_ldif = BuildDnLdifWriter('dc=more', dn_ldif)
    eq_([], mock_ldif_writer.called_with)
    dn2_ldif.unparse('cn=test', dict(foo='bar'))
    eq_([('cn=test,dc=more,dc=yup', dict(foo='bar'))],
         mock_ldif_writer.called_with)
コード例 #8
0
def test_dn_nests_using_with():
    mock_ldif_writer = MockLdifWriter()
    with BuildDnLdifWriter('dc=yup', mock_ldif_writer) as ldif_dn:
        ldif_dn.unparse('cn=test', dict(foo='bar'))
        with ldif_dn.extend('dc=more') as more_ldif:
            more_ldif.unparse('cn=test2', dict(boo='baz'))
    eq_([('cn=test,dc=yup', dict(foo='bar')),
         ('cn=test2,dc=more,dc=yup', dict(boo='baz'))],
        mock_ldif_writer.called_with)
コード例 #9
0
def test_full_dn():
    mock_ldif_writer = MockLdifWriter()
    eq_(None, full_dn(mock_ldif_writer))
    bl1 = BuildDnLdifWriter('dc=yup', mock_ldif_writer)
    eq_('dc=yup', bl1.full_dn())
    eq_('dc=yup', full_dn(bl1))
    bl2 = BuildDnLdifWriter('ou=nope', bl1)
    eq_('ou=nope,dc=yup', bl2.full_dn())
    eq_('ou=nope,dc=yup', full_dn(bl2))