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_match_refs_value_not_found_fail(): stores = constraints.Stores() root_element = Element('root', value=None, path='/component-0,test') ref_element = Element( 'memoryMapRef', value='myMemoryMap', path='/component-0,test/busInterface-0,/memoryMapRef-0,@memoryMapRef') constraints.InitKeyStore('memoryMapKey').to_python(root_element, path=root_element.path, stores=stores) kr = constraints.SetupKeyRefsStore('memoryMapKey') kr.to_python(ref_element, stores=stores) constraints.match_refs(stores)
def test_match_refs_pass(): stores = constraints.Stores() root_element = Element('root', value=None, path='/component-0,test') key_element = Element( 'name', value='myMemoryMap', path='/component-0,test/memoryMap-0,myMemoryMap/name-0,') ref_element = Element( 'memoryMapRef', value='myMemoryMap', path='/component-0,test/busInterface-0,/memoryMapRef-0,@memoryMapRef') constraints.InitKeyStore('memoryMapKey').to_python(root_element, stores=stores) constraints.CheckKeys(key_names='memoryMapKey', level=2).to_python(key_element, stores=stores) kr = constraints.SetupKeyRefsStore('memoryMapKey') kr.to_python(ref_element, stores=stores) constraints.match_refs(stores) targets = { '/component-0,test/busInterface-0,/memoryMapRef-0,@memoryMapRef': '/component-0,test/memoryMap-0,myMemoryMap/name-0,' } nose.tools.eq_(stores.refStore.targets, targets)
def test_setup_key_refs_store_value_empty_fail(): stores = constraints.Stores() ks = constraints.SetupKeyRefsStore('TestKeyRef') el = Element('test', value='', path='/') ks.to_python(el.value, path=el.path, stores=stores)
def test_setup_key_refs_store_value_none_fail(): stores = constraints.Stores() ks = constraints.SetupKeyRefsStore('TestKeyRef') ks.to_python(None, path='/', stores=stores)