def test_id_count_1_pass():
    stores = constraints.Stores()
    ks = constraints.ID()
    el = Element('test', path='/el42-0,', attributes=dict(id='ID42'))
    id_element = Element('id', path=el.path + '@id', value=el.attributes['id'])
    ks.to_python(id_element, stores=stores)
    actual = stores.idStore.id_count()
    nose.tools.eq_(actual, 1)
def test_match_id_pass():
    stores = constraints.Stores()
    path = '/root-0,'
    ck = constraints.ID()
    field = Element('field', value='field22', path=path + '/field-2,field22')
    ck.to_python(field, stores=stores)
    instance_path = stores.idStore.match_id('field22')
    nose.tools.eq_(instance_path, path + '/field-2,field22')
def test_check_ids_add_id_pass():
    stores = constraints.Stores()
    ks = constraints.ID()
    el = Element('test', path='/el42-0,', attributes=dict(id='ID42'))
    id_element = Element('id', path=el.path + '@id', value=el.attributes['id'])
    ks.to_python(id_element, stores=stores)
    stores.idStore.add_id('key_value', '/ads/cgfh')
    expected = {'ID:/': {'key_value': '/ads/cgfh', 'ID42': '/el42-0,@id'}}
    nose.tools.eq_(stores.idStore.keys, expected)
def test_match_idref_to_id_single_pass():
    stores = constraints.Stores()
    ci = constraints.ID()
    cr = constraints.IDREF()
    ci.to_python('ID42', path='/field-0,@id', stores=stores)
    cr.to_python('ID42', path='/ref-0,/for-0,/field-0,', stores=stores)
    constraints.match_refs(stores)
    expected = {'/ref-0,/for-0,/field-0,': '/field-0,@id'}
    nose.tools.eq_(stores.idrefStore.targets, expected)
def test_build_id1_pass():
    stores = constraints.Stores()
    ks = constraints.ID()
    ks.build(path='/', stores=stores)
    second = ks.build(path='/', stores=stores)
    nose.tools.eq_(second, 'testId1')
def test_build_id_pass():
    stores = constraints.Stores()
    ks = constraints.ID()
    actual = ks.build(path='/', stores=stores)
    nose.tools.eq_(actual, 'testId0')
def test_check_ids_single_pass():
    stores = constraints.Stores()
    ci = constraints.ID()
    ci.to_python('ID42', path='/field-0,@id', stores=stores)
    expected = {'ID:/': {'ID42': '/field-0,@id'}}
    nose.tools.eq_(stores.idStore.keys, expected)