def test_write(self): sessRec = DepiMcastSessionRecord() sessRec.LocalLcceIpAddr = "0.0.0.0" sessRec.write() sessRec.LocalLcceIpAddr = "134.123.123.213" sessRec.write() sessRec.read() self.assertEquals(sessRec.LocalLcceIpAddr, "134.123.123.213")
def test_readwrite(self): sessRec = DepiMcastSessionRecord() sessRec.updateDepiMcastSessionKey(IpAddrType=1, GroupIpAddr="10.79.31.1", SrcIpAddr="10.79.31.1", SessionId=1) self.assertEquals(sessRec.index.IpAddrType, 1) self.assertEquals(sessRec.index.SrcIpAddr, "10.79.31.1") self.assertEquals(sessRec.index.SessionId, 1) sessRec.write() # get_all ret = [] for ses in sessRec.get_all(): ret.append(ses) self.assertEquals(len(ret), 1) sessRec = None sessRec = DepiMcastSessionRecord() sessRec.updateDepiMcastSessionKey(IpAddrType=1, GroupIpAddr="10.79.31.1", SrcIpAddr="10.79.31.1", SessionId=1) sessRec.read() self.assertEquals(sessRec.index.IpAddrType, 1) self.assertEquals(sessRec.index.GroupIpAddr, "10.79.31.1") self.assertEquals(sessRec.index.SrcIpAddr, "10.79.31.1") self.assertEquals(sessRec.index.SessionId, 1) self.assertEquals(sessRec.JoinTime, "") self.assertEquals(sessRec.LocalLcceIpAddr, "") self.assertEquals(sessRec.RemoteLcceIpAddr, "") # modify the property currtime = Convert.pack_timestamp_to_string(time.time()) sessRec.JoinTime = currtime sessRec.write() sessRec.read() self.assertEquals(sessRec.index.IpAddrType, 1) self.assertEquals(sessRec.index.GroupIpAddr, "10.79.31.1") self.assertEquals(sessRec.index.SrcIpAddr, "10.79.31.1") self.assertEquals(sessRec.index.SessionId, 1) self.assertEquals(sessRec.JoinTime, currtime) self.assertEquals(sessRec.LocalLcceIpAddr, "") self.assertEquals(sessRec.RemoteLcceIpAddr, "") # get_all ret = [] for ses in sessRec.get_all(): ret.append(ses) self.assertEquals(len(ret), 1)