netwatch.py/netaddr-0.7.10/netaddr/tests/2.x/eui/eui.txt

206 lines
2.9 KiB
Plaintext

=IEEE EUI-64 Tests=
Copyright (c) 2008-2012, David P. D. Moss. All rights reserved.
{{{
>>> from netaddr import *
}}}
IEEE EUI-64 tests.
{{{
>>> eui = EUI('00-1B-77-FF-FE-49-54-FD')
>>> eui
EUI('00-1B-77-FF-FE-49-54-FD')
>>> eui.oui
OUI('00-1B-77')
>>> eui.ei
'FF-FE-49-54-FD'
>>> eui.eui64()
EUI('00-1B-77-FF-FE-49-54-FD')
>>> mac = EUI('00-0F-1F-12-E7-33')
>>> ip = mac.ipv6_link_local()
>>> ip
IPAddress('fe80::20f:1fff:fe12:e733')
>>> mac.eui64()
EUI('00-0F-1F-FF-FE-12-E7-33')
}}}
Individual Address Block tests.
{{{
>>> lower_eui = EUI('00-50-C2-05-C0-00')
>>> upper_eui = EUI('00-50-C2-05-CF-FF')
>>> lower_eui.is_iab()
True
>>> str(lower_eui.oui)
'00-50-C2'
>>> str(lower_eui.iab)
'00-50-C2-05-C0-00'
>>> lower_eui.ei
'05-C0-00'
>>> int(lower_eui.oui) == 0x0050c2
True
>>> int(lower_eui.iab) == 0x0050c205c
True
>>> upper_eui.is_iab()
True
>>> str(upper_eui.oui)
'00-50-C2'
>>> str(upper_eui.iab)
'00-50-C2-05-C0-00'
>>> upper_eui.ei
'05-CF-FF'
>>> int(upper_eui.oui) == 0x0050c2
True
>>> int(upper_eui.iab) == 0x0050c205c
True
}}}
Constructor tests.
{{{
>>> eui = EUI('00-90-96-AF-CC-39')
>>> eui == EUI('0-90-96-AF-CC-39')
True
>>> eui == EUI('00-90-96-af-cc-39')
True
>>> eui == EUI('00:90:96:AF:CC:39')
True
>>> eui == EUI('00:90:96:af:cc:39')
True
>>> eui == EUI('0090-96AF-CC39')
True
>>> eui == EUI('0090:96af:cc39')
True
>>> eui == EUI('009096-AFCC39')
True
>>> eui == EUI('009096:AFCC39')
True
>>> eui == EUI('009096AFCC39')
True
>>> eui == EUI('009096afcc39')
True
>>> EUI('01-00-00-00-00-00') == EUI('010000000000')
True
>>> EUI('01-00-00-00-00-00') == EUI('10000000000')
True
>>> EUI('01-00-00-01-00-00') == EUI('010000:010000')
True
>>> EUI('01-00-00-01-00-00') == EUI('10000:10000')
True
}}}
EUI-48 and EUI-64 indentifiers of the same value are *not* equivalent.
{{{
>>> eui48 = EUI('01-00-00-01-00-00')
>>> int(eui48) == 1099511693312
True
>>> eui64 = EUI('00-00-01-00-00-01-00-00')
>>> int(eui64) == 1099511693312
True
>>> eui48 == eui64
False
}}}
Sortability
{{{
>>> import random
>>> eui_list = [EUI(0, 64), EUI(0), EUI(0xffffffffffff, dialect=mac_unix), EUI(0x1000000000000)]
>>> random.shuffle(eui_list)
>>> eui_list.sort()
>>> for eui in eui_list:
... str(eui), eui.version
('00-00-00-00-00-00', 48)
('ff:ff:ff:ff:ff:ff', 48)
('00-00-00-00-00-00-00-00', 64)
('00-01-00-00-00-00-00-00', 64)
}}}
Persistence
{{{
>>> import pickle
>>> eui1 = EUI('00-00-00-01-02-03')
>>> eui2 = pickle.loads(pickle.dumps(eui1))
>>> eui1 == eui2
True
>>> eui1 = EUI('00-00-00-01-02-03', dialect=mac_cisco)
>>> eui2 = pickle.loads(pickle.dumps(eui1))
>>> eui1 == eui2
True
>>> eui1.dialect == eui2.dialect
True
>>> oui1 = EUI('00-00-00-01-02-03').oui
>>> oui2 = pickle.loads(pickle.dumps(oui1))
>>> oui1 == oui2
True
>>> oui1.records == oui2.records
True
>>> iab1 = EUI('00-50-C2-00-1F-FF').iab
>>> iab2 = pickle.loads(pickle.dumps(iab1))
>>> iab1 == iab2
True
>>> iab1.record == iab2.record
True
}}}