From d1f41da8b5b875ffce191829f72a73e99d6a5efe Mon Sep 17 00:00:00 2001 From: asarfaty Date: Sun, 1 Mar 2020 14:10:01 +0200 Subject: [PATCH] NSX|V3: Fix broken unit tests Commit Ibad52cca60131e970447536fd22c4f4440c66d34 groke the unit tests by removing a mock that is needed by the plugin tests. Adding back the mock in the plugin tests context. Change-Id: I85c191c3c15aedc0740cb3c23990c0ea0b646fe7 --- vmware_nsx/tests/unit/nsx_v3/test_plugin.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py index 96f6fc8626..5a7b473ae2 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py @@ -96,6 +96,18 @@ def _return_id_key_list(*args, **kwargs): return [{'id': uuidutils.generate_uuid()}] +def _mock_add_rules_in_section(*args): + # NOTE(arosen): the code in the neutron plugin expects the + # neutron rule id as the display_name. + rules = args[0] + return { + 'rules': [ + {'display_name': rule['display_name'], + 'id': uuidutils.generate_uuid()} + for rule in rules + ]} + + def _mock_nsx_backend_calls(): mock.patch("vmware_nsxlib.v3.client.NSX3Client").start() @@ -189,6 +201,9 @@ def _mock_nsx_backend_calls(): "get_transport_zones", return_value=[NSX_TZ_NAME, mock.ANY]).start() + mock.patch("vmware_nsxlib.v3.security.NsxLibFirewallSection.add_rules", + side_effect=_mock_add_rules_in_section).start() + class NsxV3PluginTestCaseMixin(test_plugin.NeutronDbPluginV2TestCase, nsxlib_testcase.NsxClientTestCase):