Merge "Fix dynamic_inventory.py test bug"

This commit is contained in:
Jenkins
2016-05-09 16:44:24 +00:00
committed by Gerrit Code Review
2 changed files with 10 additions and 6 deletions

View File

@@ -55,11 +55,14 @@ class MultipleHostsWithOneIPError(Exception):
self.assigned_host = assigned_host
self.new_host = new_host
error_msg = ("ip address:{} has already been "
"assigned to host:{}, cannot "
"assign same ip to host:{}")
# Order the hostnames for predictable testing.
host_list = [assigned_host, new_host]
host_list.sort()
error_msg = ("Both host:{} and host:{} have "
"address:{} assigned. Cannot "
"assign same ip to both hosts")
self.message = error_msg.format(ip, assigned_host, new_host)
self.message = error_msg.format(host_list[0], host_list[1], ip)
def __str__(self):
return self.message

View File

@@ -434,8 +434,9 @@ class TestConfigChecks(unittest.TestCase):
"aio1", "hap")
with self.assertRaises(di.MultipleHostsWithOneIPError) as context:
get_inventory()
expectedLog = ("ip address:172.29.236.100 has already been assigned"
" to host:aio1, cannot assign same ip to host:hap")
expectedLog = ("Both host:aio1 and host:hap have "
"address:172.29.236.100 assigned. Cannot "
"assign same ip to both hosts")
self.assertEqual(context.exception.message, expectedLog)
def tearDown(self):