def test_check_idref_single_pass(): stores = constraints.Stores() cr = constraints.IDREF() cr.to_python('ID42', path='/ref-0,/for-0,/field-0,', stores=stores) expected = constraints.KeyRef(key_name='ID', key_value='ID42', ref_path='/ref-0,/for-0,/field-0,') nose.tools.eq_(stores.idrefStore.refs[0], expected)
def test_set_id_ref_store_pass(): idr = constraints.IDREFStore() idr.add_idref('key_value', 'ref_path') expected = [ constraints.KeyRef(key_name='ID', key_value='key_value', ref_path='ref_path') ] nose.tools.eq_(idr.refs, expected)
def test_setup_key_refs_store_build_no_value_pass(): stores = constraints.Stores() ks = constraints.SetupKeyRefsStore('TestKeyRef') path = '/root-0,/test' el = Element('test', value='refName', path=path) ks.build(path=el.path, stores=stores) nose.tools.eq_(stores.refStore.refs, [ constraints.KeyRef(key_name='TestKeyRef', key_value='TestKeyRef0', ref_path='/root-0,/test') ])
def test_setup_key_refs_store_string_validator_pass(): stores = constraints.Stores() ks = constraints.SetupKeyRefsStore('TestKeyRef', string_validator_instance=Name()) path = '/root-0,/test' el = Element('test', value='refName', path=path) ks.to_python(el, stores=stores) nose.tools.eq_(stores.refStore.refs, [ constraints.KeyRef(key_name='TestKeyRef', key_value='refName', ref_path='/root-0,/test') ])
def test_key_sub_class_name_two_keys_pass(): class TestKeyName(constraints.KeyName): key_names = 'Key1 Key2'.split() refer_key_name = 'referKey' level = 1 ks = constraints.InitKeyStore('Key2') stores = constraints.Stores() root_path = '/root-0,' ks.to_python(None, path=root_path, stores=stores) u_name = TestKeyName() key_path = root_path + '/child-1,prefixed:name' actual = u_name.to_python('prefixed:name', path=key_path, stores=stores) nose.tools.eq_(stores.refStore.refs, [ constraints.KeyRef(key_name='referKey', key_value='prefixed:name', ref_path='/root-0,/child-1,prefixed:name') ])