summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasayuki Igawa <mas-igawa@ut.jp.nec.com>2015-03-25 12:19:29 -0400
committerMasayuki Igawa <mas-igawa@ut.jp.nec.com>2015-03-25 16:17:52 -0400
commit49882154c65935b00282391b43555ce4a653f951 (patch)
tree9411087f52ae82f3e82953ca83936ddf0e83a072
parent32369dbbf62119215d58d0b557f2ba0e170ebb93 (diff)
downloadtempest-lib-49882154c65935b00282391b43555ce4a653f951.tar.gz
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
-rw-r--r--tempest_lib/tests/common/utils/test_data_utils.py38
1 files changed, 38 insertions, 0 deletions
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)