예제 #1
0
def test_host_raises_exception_on_no_response(network):
    conf.iface = 'lo'
    host = utils.Host('93.34.12.122')
    host.arp_timeout = 1
    host.arp_retries = 0
    with pytest.raises(utils.AddressNotResolvedError) as e:
        host.resolve_mac()
예제 #2
0
def test_host_resolves_correct_mac(container):
    container_details = container.attrs['NetworkSettings']['Networks'][
        test_network_name]
    conf.iface = 'br-{}'.format(container_details['NetworkID'][:12])
    host = utils.Host(container_details['IPAddress'])
    host.resolve_mac()
    assert host.mac == netaddr.EUI(container_details['MacAddress'])
예제 #3
0
def test_host_has_vendor_attribute_and_is_correctly_set():
    assert utils.Host('1.2.3.4', mac='b4:99:ba:00:00:00').vendor \
        == 'Hewlett Packard'
    assert utils.Host('1.2.3.4', mac='00:50:ba:00:00:00').vendor \
        == 'D-Link Corporation'
예제 #4
0
def test_host_default_mac_returns_correct_bool():
    assert bool(utils.Host('1.2.3.4', mac='12:34:56:78:9a:bc').mac) is True
    assert bool(utils.Host('1.2.3.4', mac='ff:ff:ff:ff:ff:ff').mac) is False
    assert bool(utils.Host('1.2.3.4').mac) is False
예제 #5
0
def test_host_takes_optional_mac_argument_and_sets_mac_attr_as_eui_object():
    assert utils.Host('1.2.3.4', mac='12:34:56:78:9a:bc').mac \
        == netaddr.EUI('12:34:56:78:9a:bc')
    assert utils.Host('1.1.1.1', mac='ab:cd:ef:12:34:56').mac \
        == netaddr.EUI('ab:cd:ef:12:34:56')
    assert utils.Host('1.1.1.1').mac is utils.MAC.broadcast
예제 #6
0
def test_host_takes_argument_ip_and_sets_ip_attr_as_netaddr_ipaddress_object():
    assert utils.Host('1.2.3.4').ip == netaddr.IPAddress('1.2.3.4')
    assert utils.Host('23.22.11.58').ip == netaddr.IPAddress('23.22.11.58')