From 88b7db0e0c4d633748f454f4977c13c253012769 Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Thu, 1 Dec 2022 17:53:42 -0500 Subject: [PATCH] Mock ls_get in OVN metadata delete network unit test "TypeError: 'Mock' object is not iterable" could possibly be triggered by test_metadata_port_on_network_delete() since there is a missing mock of the return value for ls_get. Although I did not see the error described in the bug, I did verify ls_get was returning an incorrect value by printing it in the code, which after this patch was a fake row. Change-Id: Ib1f204c98eee96321c7befebf94012dc2c80b1e8 Closes-bug: #1973731 --- .../plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py index 1d5cc3a180d..51f75bc43b3 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py +++ b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py @@ -4094,6 +4094,9 @@ class TestOVNMechanismDriverMetadataPort(MechDriverSetupBase, Check that the metadata port is deleted when a network is deleted. """ + nb_idl = self.mech_driver._ovn_client._nb_idl + nb_idl.ls_get.return_value.execute.return_value = ( + fakes.FakeOvsdbRow.create_one_ovsdb_row(attrs={'ports': []})) net = self._make_network(self.fmt, name="net1", admin_state_up=True) network_id = net['network']['id'] req = self.new_delete_request('networks', network_id)