From 49882154c65935b00282391b43555ce4a653f951 Mon Sep 17 00:00:00 2001 From: Masayuki Igawa Date: Wed, 25 Mar 2015 12:19:29 -0400 Subject: Add a unit test for get_ipv6_addr_by_EUI64 This commit adds a unit test for get_ipv6_addr_by_eui64. Change-Id: I5290238b5f5e7ed8c0c08fe4e08e7af326ed916b --- tempest_lib/tests/common/utils/test_data_utils.py | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tempest_lib/tests/common/utils/test_data_utils.py b/tempest_lib/tests/common/utils/test_data_utils.py index 08566f4..a231964 100644 --- a/tempest_lib/tests/common/utils/test_data_utils.py +++ b/tempest_lib/tests/common/utils/test_data_utils.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +import netaddr from tempest_lib.common.utils import data_utils from tempest_lib.tests import base @@ -92,3 +93,40 @@ class TestDataUtils(base.TestCase): actual = data_utils.random_bytes(size=2048) self.assertRegexpMatches(actual, "^[\x00-\xFF]{2048}") + + def test_get_ipv6_addr_by_EUI64(self): + actual = data_utils.get_ipv6_addr_by_EUI64('2001:db8::', + '00:16:3e:33:44:55') + self.assertIsInstance(actual, netaddr.IPAddress) + self.assertEqual(actual, + netaddr.IPAddress('2001:db8::216:3eff:fe33:4455')) + + def test_get_ipv6_addr_by_EUI64_with_IPv4_prefix(self): + ipv4_prefix = '10.0.8' + mac = '00:16:3e:33:44:55' + self.assertRaises(TypeError, data_utils.get_ipv6_addr_by_EUI64, + ipv4_prefix, mac) + + def test_get_ipv6_addr_by_EUI64_bad_cidr_type(self): + bad_cidr = 123 + mac = '00:16:3e:33:44:55' + self.assertRaises(TypeError, data_utils.get_ipv6_addr_by_EUI64, + bad_cidr, mac) + + def test_get_ipv6_addr_by_EUI64_bad_cidr_value(self): + bad_cidr = 'bb' + mac = '00:16:3e:33:44:55' + self.assertRaises(TypeError, data_utils.get_ipv6_addr_by_EUI64, + bad_cidr, mac) + + def test_get_ipv6_addr_by_EUI64_bad_mac_value(self): + cidr = '2001:db8::' + bad_mac = '00:16:3e:33:44:5Z' + self.assertRaises(TypeError, data_utils.get_ipv6_addr_by_EUI64, + cidr, bad_mac) + + def test_get_ipv6_addr_by_EUI64_bad_mac_type(self): + cidr = '2001:db8::' + bad_mac = 99999999999999999999 + self.assertRaises(TypeError, data_utils.get_ipv6_addr_by_EUI64, + cidr, bad_mac) -- cgit v1.2.1