예제 #1
0
 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")
예제 #2
0
 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))
예제 #3
0
 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"))