def testStatus(self): eth = qca83xx_ethernet.EthernetInterfaceQca83xx(portnum=3, mac=self.mac) self.assertEqual(eth.Status, 'Error') eth = qca83xx_ethernet.EthernetInterfaceQca83xx(portnum=4, mac=self.mac) self.assertEqual(eth.Status, 'Down')
def testEmptyFile(self): qca83xx_ethernet.QCA83XX_JSON[0] = 'testdata/qca83xx_ethernet/empty' eth = qca83xx_ethernet.EthernetInterfaceQca83xx(portnum=1, mac=self.mac) ac = eth.GetAssociatedDevices() self.assertEqual(len(ac), 0) self.assertEqual(eth.Stats.BytesSent, 0) self.assertEqual(eth.Stats.BytesReceived, 0)
def testGetAssociatedDevices(self): eth = qca83xx_ethernet.EthernetInterfaceQca83xx(portnum=1, mac=self.mac) ac = eth.GetAssociatedDevices() self.assertEqual(len(ac), 3) self.assertEqual(ac[0]['PhysAddress'], 'f8:8f:ca:00:00:01') self.assertEqual(ac[1]['PhysAddress'], 'f8:8f:ca:00:00:02') self.assertEqual(ac[2]['PhysAddress'], 'f8:8f:ca:00:00:03')
def testFields(self): eth = qca83xx_ethernet.EthernetInterfaceQca83xx(portnum=2, mac=self.mac) self.assertEqual(eth.MaxBitRate, 100) self.assertEqual(eth.DuplexMode, 'Full') self.assertEqual(eth.Status, 'Up') self.assertEqual(eth.MACAddress, self.mac) self.assertFalse(eth.Upstream)
def testMissingFile(self): qca83xx_ethernet.QCA83XX_JSON[0] = '/nosuchfile' eth = qca83xx_ethernet.EthernetInterfaceQca83xx(portnum=1, mac=self.mac) ac = eth.GetAssociatedDevices() self.assertEqual(len(ac), 0) self.assertEqual(eth.Stats.BytesSent, 0) self.assertEqual(eth.Stats.BytesReceived, 0)
def __init__(self): super(Ethernet, self).__init__() self.InterfaceList = { '1': ethernet.EthernetInterfaceLinux26(ifname='eth0'), '2': qca83xx_ethernet.EthernetInterfaceQca83xx(portnum=1, mac='00:00:00:00:00:00') }
def testStats(self): eth = qca83xx_ethernet.EthernetInterfaceQca83xx(portnum=1, mac=self.mac) self.assertEqual(eth.Stats.BytesSent, 17000000000000000L) self.assertEqual(eth.Stats.BytesReceived, 36000000000000000L) self.assertEqual(eth.Stats.PacketsSent, 15 + 19 + 25) self.assertEqual(eth.Stats.PacketsReceived, 31 + 34 + 39) self.assertEqual(eth.Stats.ErrorsSent, 98) self.assertEqual(eth.Stats.ErrorsReceived, 99) self.assertEqual(eth.Stats.UnicastPacketsSent, 25) self.assertEqual(eth.Stats.UnicastPacketsReceived, 31) self.assertEqual(eth.Stats.MulticastPacketsSent, 15) self.assertEqual(eth.Stats.MulticastPacketsReceived, 39) self.assertEqual(eth.Stats.BroadcastPacketsSent, 19) self.assertEqual(eth.Stats.BroadcastPacketsReceived, 34) self.assertEqual(eth.Stats.DiscardPacketsSent, 0) self.assertEqual(eth.Stats.DiscardPacketsReceived, 0) self.assertEqual(eth.Stats.UnknownProtoPacketsReceived, 0)
def testValidateExports(self): eth = qca83xx_ethernet.EthernetInterfaceQca83xx(portnum=1, mac=self.mac) tr.handle.ValidateExports(eth)