diff options
author | Dan Sneddon <dsneddon@redhat.com> | 2017-01-27 14:58:53 -0800 |
---|---|---|
committer | Dan Sneddon <dsneddon@redhat.com> | 2017-01-27 15:02:15 -0800 |
commit | 354abb5b6ebf444341a717addd4cf9b1fe77ca00 (patch) | |
tree | 9fa549db06d95b5e0a9da59b659f284db5c6e4d2 /os_net_config/tests/test_objects.py | |
parent | 60f043152dedf04c335a049feedb502b194fbc02 (diff) |
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
Diffstat (limited to 'os_net_config/tests/test_objects.py')
-rw-r--r-- | os_net_config/tests/test_objects.py | 12 |
1 files changed, 6 insertions, 6 deletions
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): |