def test_is_connected_when_wireless_and_carrier_active(self): """is_connected is True if wireless /sys/net/devname/carrier is 1.""" self.assertFalse(net.is_connected('eth0')) ensure_file(os.path.join(self.sysdir, 'eth0', 'wireless')) self.assertFalse(net.is_connected('eth0')) write_file(os.path.join(self.sysdir, 'eth0', 'carrier'), "1") self.assertTrue(net.is_connected('eth0'))
def test_is_connected_when_physically_connected(self): """is_connected is True when /sys/net/devname/iflink reports 2.""" self.assertFalse(net.is_connected('eth0')) write_file(os.path.join(self.sysdir, 'eth0', 'iflink'), "2") self.assertTrue(net.is_connected('eth0'))
def is_connected(self, devname: DeviceName) -> bool: return net.is_connected(devname)