summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-07-16 20:46:27 -0700
committerRoss Brattain <ross.b.brattain@intel.com>2017-07-17 03:56:37 +0000
commit7b4f2bdb386eacd62f4f8e9e67d0c826adccc3b0 (patch)
tree8cb8fecfdcb94d353e52f6c1d35b5f1db9005bc6 /tests
parent33b439426dac57bc8448df1bb485138550235740 (diff)
test_heat: ipaddress expects unicode inputs
weird error E AddressValueError: '10.20.0.0/15' does not appear to be an IPv4 or IPv6 network. Did you pass in a bytes (str in Python 2) instead of a unicode object? I guess we need to convert the stack.outputs mock to unicode FAILED tests/unit/benchmark/contexts/test_heat.py:137 (HeatContextTestCase.test_add_server_port) self = <tests.unit.benchmark.contexts.test_heat.HeatContextTestCase testMethod=test_add_server_port> def test_add_server_port(self): network1 = mock.MagicMock() network1.vld_id = 'vld111' network2 = mock.MagicMock() network2.vld_id = 'vld777' self.test_context.name = 'foo' self.test_context.stack = mock.MagicMock() self.test_context.networks = { 'a': network1, 'c': network2, } self.test_context.stack.outputs = { 'b': '10.20.30.45', 'b-subnet_id': 1, 'foo-a-subnet-cidr': '10.20.0.0/15', 'foo-a-subnet-gateway_ip': '10.20.30.1', 'b-mac_address': '00:01', 'b-device_id': 'dev21', 'b-network_id': 'net789', 'd': '40.30.20.15', 'd-subnet_id': 2, 'foo-c-subnet-cidr': '40.30.0.0/18', 'foo-c-subnet-gateway_ip': '40.30.20.254', 'd-mac_address': '00:10', 'd-device_id': 'dev43', 'd-network_id': 'net987', } server = mock.MagicMock() server.ports = OrderedDict([ ('a', {'stack_name': 'b'}), ('c', {'stack_name': 'd'}), ]) expected = { "private_ip": '10.20.30.45', "subnet_id": 1, "subnet_cidr": '10.20.0.0/15', "network": '10.20.0.0', "netmask": '255.254.0.0', "gateway_ip": '10.20.30.1', "mac_address": '00:01', "device_id": 'dev21', "network_id": 'net789', "network_name": 'a', "local_mac": '00:01', "local_ip": '10.20.30.45', "vld_id": 'vld111', } > self.test_context.add_server_port(server) tests/unit/benchmark/contexts/test_heat.py:186: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ yardstick/benchmark/contexts/heat.py:307: in add_server_port network_name, port['stack_name'], self.stack.outputs) yardstick/benchmark/contexts/heat.py:315: in make_interface_dict subnet_ip = ipaddress.ip_network(subnet_cidr) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ address = '10.20.0.0/15', strict = True def ip_network(address, strict=True): """Take an IP string/int and return an object of the correct type. Args: address: A string or integer, the IP network. Either IPv4 or IPv6 networks may be supplied; integers less than 2**32 will be considered to be IPv4 by default. Returns: An IPv4Network or IPv6Network object. Raises: ValueError: if the string passed isn't either a v4 or a v6 address. Or if the network has host bits set. """ try: return IPv4Network(address, strict) except (AddressValueError, NetmaskValueError): pass try: return IPv6Network(address, strict) except (AddressValueError, NetmaskValueError): pass if isinstance(address, bytes): raise AddressValueError( '%r does not appear to be an IPv4 or IPv6 network. ' 'Did you pass in a bytes (str in Python 2) instead of' > ' a unicode object?' % address) E AddressValueError: '10.20.0.0/15' does not appear to be an IPv4 or IPv6 network. Did you pass in a bytes (str in Python 2) instead of a unicode object? ../../yardstick/yardstick_venv/lib/python2.7/site-packages/ipaddress.py:199: AddressValueError Change-Id: Ie3b087a26a054203573eaa9b13c3e90152bba6a9 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/benchmark/contexts/test_heat.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/tests/unit/benchmark/contexts/test_heat.py b/tests/unit/benchmark/contexts/test_heat.py
index c739f33ff..ae57402c0 100644
--- a/tests/unit/benchmark/contexts/test_heat.py
+++ b/tests/unit/benchmark/contexts/test_heat.py
@@ -147,20 +147,20 @@ class HeatContextTestCase(unittest.TestCase):
'c': network2,
}
self.test_context.stack.outputs = {
- 'b': '10.20.30.45',
- 'b-subnet_id': 1,
- 'foo-a-subnet-cidr': '10.20.0.0/15',
- 'foo-a-subnet-gateway_ip': '10.20.30.1',
- 'b-mac_address': '00:01',
- 'b-device_id': 'dev21',
- 'b-network_id': 'net789',
- 'd': '40.30.20.15',
- 'd-subnet_id': 2,
- 'foo-c-subnet-cidr': '40.30.0.0/18',
- 'foo-c-subnet-gateway_ip': '40.30.20.254',
- 'd-mac_address': '00:10',
- 'd-device_id': 'dev43',
- 'd-network_id': 'net987',
+ u'b': u'10.20.30.45',
+ u'b-subnet_id': 1,
+ u'foo-a-subnet-cidr': u'10.20.0.0/15',
+ u'foo-a-subnet-gateway_ip': u'10.20.30.1',
+ u'b-mac_address': u'00:01',
+ u'b-device_id': u'dev21',
+ u'b-network_id': u'net789',
+ u'd': u'40.30.20.15',
+ u'd-subnet_id': 2,
+ u'foo-c-subnet-cidr': u'40.30.0.0/18',
+ u'foo-c-subnet-gateway_ip': u'40.30.20.254',
+ u'd-mac_address': u'00:10',
+ u'd-device_id': u'dev43',
+ u'd-network_id': u'net987',
}
server = mock.MagicMock()
server.ports = OrderedDict([