def test__no_mac_raises_macaddressnotavailable(self): mock_ioerror = IOError() mock_ioerror.errno = errno.EOPNOTSUPP self.patch(detect_module.fcntl, "ioctl").side_effect = mock_ioerror sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # Drive-by test for the strerror() call. with ExpectedException(MACAddressNotAvailable, ".*not supported.*"): get_interface_mac(sock, "lo")
def test__invalid_interface_raises_interfacenotfound(self): sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) with ExpectedException(InterfaceNotFound): get_interface_mac(sock, factory.make_unicode_string(size=15))
def test__loopback_has_zero_mac(self): # It's a lame test, but what other network interfaces can we reliably # test this on? sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.assertEqual("00:00:00:00:00:00", get_interface_mac(sock, "lo"))