Don't modify objects directly

We should use patch for this. pytest was highlighting the issue by way
of an 'AttributeError'.

Change-Id: Ide447262bf883fe00f4f98e746011b1b595789e1
This commit is contained in:
Stephen Finucane 2018-01-26 17:00:12 +00:00
parent 33f544e30f
commit 1268b34252
1 changed files with 3 additions and 2 deletions

View File

@ -149,9 +149,10 @@ class IptablesFirewallTestCase(test.NoDBTestCase):
inst.info_cache.deleted = False
return inst
@mock.patch.object(linux_net.iptables_manager, "execute")
@mock.patch.object(objects.InstanceList, "get_by_security_group_id")
@mock.patch.object(objects.SecurityGroupRuleList, "get_by_instance")
def test_static_filters(self, mock_secrule, mock_instlist):
def test_static_filters(self, mock_secrule, mock_instlist, fake_execute):
UUID = "2674993b-6adb-4733-abd9-a7c10cc1f146"
SRC_UUID = "0e0a76b2-7c52-4bc0-9a60-d83017e42c1a"
instance_ref = self._create_instance_ref(UUID)
@ -247,7 +248,7 @@ class IptablesFirewallTestCase(test.NoDBTestCase):
network_model = _fake_network_info(self, 1)
linux_net.iptables_manager.execute = fake_iptables_execute
fake_execute.side_effect = fake_iptables_execute
self.stub_out('nova.objects.Instance.get_network_info',
lambda instance: network_model)