assert( t.pyStr() == '{"1": 0., 0: "1", 2: V3f(0, 1, 2)}' ) def testToTupleString(): t = n.ObjectTable() assert( t.tupStr() == "{}" ) t[0] = '1' t['1'] = 0.0 t[2] = p.V3f(0,1,2) assert( t.tupStr() == '{"1": 0., 0: "1", 2: (0, 1, 2)}' ) exec("m="+t.tupStr()) assert( m == {"1":0.,0:"1",2:(0,1,2)}) ########### main print("testing napalm v" + n.getAPIVersion() + " (core)...") assert(n.getTotalClientBytes() == 0) testTypes() testFile() testBuf() testTable() testBufCloning() testTableCloning() testSerializeBruteForce() for ft in fileTypes: testIntBufSerialize(ft) testV3fBufSerialize(ft)
import napalm.core as nc import napalm.parsing as np print("testing napalm v" + nc.getAPIVersion() + " (parsing)...") # create napalm table t = nc.ObjectTable() t[1] = "one" t["two"] = 2 t["tbl"] = nc.ObjectTable() t["tbl"][55] = 66 t["tbl"]["hey"] = "ho" # parse equivalent python dict s = "{1:'one', 'two':2, 'tbl':{55:66, 'hey':'ho'}}" t_pydict = np.parseDict(s) # parse equivalent xml # TODO this isn't useful until we have full collapse supported # test for equality assert(nc.areEqual(t, t_pydict)) # test for equality after clone t_ = t.clone() assert(nc.areEqual(t_, t_pydict)) # test for inequality after entry addition t_ = t.clone() t_[2] = "extra_entry"
def testToTupleString(): t = n.ObjectTable() assert (t.tupStr() == "{}") t[0] = '1' t['1'] = 0.0 t[2] = p.V3f(0, 1, 2) assert (t.tupStr() == '{"1": 0., 0: "1", 2: (0, 1, 2)}') exec("m=" + t.tupStr()) assert (m == {"1": 0., 0: "1", 2: (0, 1, 2)}) ########### main print("testing napalm v" + n.getAPIVersion() + " (core)...") assert (n.getTotalClientBytes() == 0) testTypes() testFile() testBuf() testTable() testBufCloning() testTableCloning() testSerializeBruteForce() for ft in fileTypes: testIntBufSerialize(ft) testV3fBufSerialize(ft)
import napalm.core as nc import napalm.parsing as np print("testing napalm v" + nc.getAPIVersion() + " (parsing)...") # create napalm table t = nc.ObjectTable() t[1] = "one" t["two"] = 2 t["tbl"] = nc.ObjectTable() t["tbl"][55] = 66 t["tbl"]["hey"] = "ho" # parse equivalent python dict s = "{1:'one', 'two':2, 'tbl':{55:66, 'hey':'ho'}}" t_pydict = np.parseDict(s) # parse equivalent xml # TODO this isn't useful until we have full collapse supported # test for equality assert (nc.areEqual(t, t_pydict)) # test for equality after clone t_ = t.clone() assert (nc.areEqual(t_, t_pydict)) # test for inequality after entry addition t_ = t.clone() t_[2] = "extra_entry" assert (not nc.areEqual(t_, t_pydict))