summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-03-26 15:54:58 +0000
committerGerrit Code Review <review@openstack.org>2015-03-26 15:54:58 +0000
commit70bbbd5ecdd27e8d680e0c9dbb0930a4eee81c9d (patch)
tree19e86a995a28958dc5c0121d0e490397fbdd056c
parentf4b8c6f133335544a9ad4500974a096e296d9950 (diff)
parent49882154c65935b00282391b43555ce4a653f951 (diff)
downloadtempest-lib-70bbbd5ecdd27e8d680e0c9dbb0930a4eee81c9d.tar.gz
Merge "Add a unit test for get_ipv6_addr_by_EUI64"
-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 fca812e..e8a7c33 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
@@ -99,3 +100,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)