From 354abb5b6ebf444341a717addd4cf9b1fe77ca00 Mon Sep 17 00:00:00 2001 From: Dan Sneddon Date: Fri, 27 Jan 2017 14:58:53 -0800 Subject: Allow ovs_extra to be specified as either a string or list This change allows the commands in ovs_extra to be expressed as a string or as a list. If a string is passed, it will be treated as a list with a single element, and other ovs_extra elements will be appended to the same list, such as fail_mode. In order for more than one command to be passed as a string, the commands will need to be separated with double-dashes, similar to the format used by OVS command-line utilities. Change-Id: I3f69e7ab96ff6e06953c3838b3e187b93545d623 --- os_net_config/tests/test_objects.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'os_net_config/tests') diff --git a/os_net_config/tests/test_objects.py b/os_net_config/tests/test_objects.py index 0ff653c..f5daf31 100644 --- a/os_net_config/tests/test_objects.py +++ b/os_net_config/tests/test_objects.py @@ -309,7 +309,7 @@ class TestBridge(base.TestCase): self.assertEqual("set bridge br-foo fail_mode=standalone", bridge.ovs_extra[1]) - def test_from_json_ovs_extra_invalid(self): + def test_from_json_ovs_extra_string(self): data = """{ "type": "ovs_bridge", "name": "br-foo", @@ -317,11 +317,11 @@ class TestBridge(base.TestCase): "ovs_fail_mode": "standalone" } """ - json_data = json.loads(data) - err = self.assertRaises(objects.InvalidConfigException, - objects.object_from_json, json_data) - expected = 'ovs_extra must be a list.' - self.assertIn(expected, six.text_type(err)) + bridge = objects.object_from_json(json.loads(data)) + self.assertTrue(2 == len(bridge.ovs_extra)) + self.assertEqual("bar", bridge.ovs_extra[0]) + self.assertEqual("set bridge br-foo fail_mode=standalone", + bridge.ovs_extra[1]) class TestLinuxBridge(base.TestCase): -- cgit 1.2.3-korg