=IEEE EUI-64 Tests=

Copyright (c) 2008-2015, 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')
>>> ip.is_link_local()
True

>>> 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

}}}

Equality check for EUI must support subclassing

{{{
>>> eui = EUI(42)
>>> class MySubclass(EUI): pass
>>> my_instance = MySubclass(42)
>>> my_instance2 = MySubclass(43)
>>> class YourSubclass(EUI): pass
>>> your_instance = YourSubclass(42)
>>> your_instance2 = YourSubclass(43)

>>> eui == my_instance
True

>>> eui == my_instance2
False

>>> my_instance == your_instance
True

>>> my_instance == your_instance2
False

>>> my_instance != your_instance2
True

}}}

Equality check for OUI must support subclassing

{{{
>>> oui = OUI('00-1B-77')
>>> class MySubclass(OUI): pass
>>> my_instance = MySubclass('00-1B-77')
>>> my_instance2 = MySubclass('00-1B-78')
>>> class YourSubclass(OUI): pass
>>> your_instance = YourSubclass('00-1B-77')
>>> your_instance2 = YourSubclass('00-1B-78')

>>> oui == my_instance
True

>>> oui != my_instance
False

>>> oui == my_instance2
False

>>> oui != my_instance2
True

>>> my_instance != your_instance
False

>>> my_instance == your_instance
True

>>> my_instance == your_instance2
False

>>> my_instance != your_instance2
True

}}}

Equality check for IAB must support subclassing

{{{
>>> iab = IAB('00-50-C2-00-00-00')
>>> class MySubclass(IAB): pass
>>> my_instance = MySubclass('00-50-C2-00-00-00')
>>> my_instance2 = MySubclass('00-50-C2-99-00-00')
>>> class YourSubclass(IAB): pass
>>> your_instance = YourSubclass('00-50-C2-00-00-00')
>>> your_instance2 = YourSubclass('00-50-C2-99-00-00')

>>> iab == my_instance
True

>>> iab != my_instance
False

>>> iab == my_instance2
False

>>> iab != my_instance2
True

>>> my_instance != your_instance
False

>>> my_instance == your_instance
True

>>> my_instance == your_instance2
False

>>> my_instance != your_instance2
True

}}}

Comparison between EUI objects and their textual representations

{{{

>>> eui = EUI('11-22-33-44-55-66')
>>> class MySubclass(EUI): pass
>>> my_instance = MySubclass('11-22-33-44-55-66')

>>> eui == '11-22-33-44-55-66'
True

>>> my_instance == '11-22-33-44-55-66'
True

>>> my_instance == '99-22-33-44-55-66'
False

>>> '11-22-33-44-55-66' >= my_instance
True

>>> my_instance > '11-22-33-44-55-00'
True

>>> my_instance < '11-22-33-44-55-00'
False

>>> my_instance <= '11-22-33-44-55-00'
False

>>> my_instance >= '11-22-33-44-55-00'
True

}}}

Check equality between OUI objects and their textual representations

{{{

>>> oui = OUI('00-1B-77')
>>> class MySubclass(OUI): pass
>>> my_instance = MySubclass('00-1B-77')

>>> oui == '00-1B-77'
True

>>> my_instance == '00-1B-77'
True

>>> my_instance == '00-1B-99'
False

}}}

Check equality between IAB objects and their textual representations
{{{

>>> eui = IAB('00-50-C2-00-00-00')
>>> class MySubclass(IAB): pass
>>> my_instance = MySubclass('00-50-C2-00-00-00')

>>> eui == '00-50-C2-00-00-00'
True

>>> my_instance == '00-50-C2-00-00-00'
True

>>> my_instance == '00-50-C2-99-00-00'
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

}}}

