Merge "Fix format of existing network in _get_or_create_network()"

This commit is contained in:
Jenkins 2015-12-09 04:21:53 +00:00 committed by Gerrit Code Review
commit 010d8aaf22
2 changed files with 9 additions and 3 deletions

View File

@ -283,7 +283,8 @@ class NeutronScenario(scenario.OpenStackScenario):
:returns: Network dict
"""
if "networks" in self.context["tenant"]:
return random.choice(self.context["tenant"]["networks"])
return {"network":
random.choice(self.context["tenant"]["networks"])}
else:
LOG.warning(_("Running this scenario without either the 'network' "
"or 'existing_network' context is deprecated"))

View File

@ -437,12 +437,17 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
if context is None:
context = {"tenant": {}}
scenario = utils.NeutronScenario(context=context)
scenario._create_network = mock.Mock()
scenario._create_network = mock.Mock(
return_value={"network": mock.Mock()})
network = scenario._get_or_create_network(network_create_args)
# ensure that the return value is the proper type either way
self.assertIn("network", network)
if "networks" in context["tenant"]:
self.assertEqual(network, context["tenant"]["networks"][0])
self.assertEqual(network,
{"network": context["tenant"]["networks"][0]})
self.assertFalse(scenario._create_network.called)
else:
self.assertEqual(network, scenario._create_network.return_value)