From 41b4e456efa7ee489b01fc8881107f1d278b3b40 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Sun, 1 Jan 2017 22:09:20 -0500 Subject: [PATCH] Make last remaining unit tests work with Neutron by default After this change all of nova/tests/unit should pass with CONF.use_neutron=True by default. The functional tests still need to be worked on but that's a later patch. Part of blueprint use-neutron-by-default Change-Id: I572a6e52196e0f0ddebfcda8e13550e2311cf0f1 --- nova/tests/unit/compute/test_compute_api.py | 3 +++ nova/tests/unit/test_utils.py | 1 + nova/tests/unit/virt/hyperv/test_vmops.py | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/nova/tests/unit/compute/test_compute_api.py b/nova/tests/unit/compute/test_compute_api.py index fe43e423f0..80072f38fa 100644 --- a/nova/tests/unit/compute/test_compute_api.py +++ b/nova/tests/unit/compute/test_compute_api.py @@ -212,6 +212,9 @@ class _ComputeAPIUnitTestMixIn(object): mock_reserve.side_effect = quota_exception + # We don't care about network validation in this test. + self.compute_api.network_api.validate_networks = ( + mock.Mock(return_value=40)) with mock.patch.object(self.compute_api, '_get_image', return_value=(image_id, {})) as mock_get_image: for min_count, message in [(20, '20-40'), (40, '40')]: diff --git a/nova/tests/unit/test_utils.py b/nova/tests/unit/test_utils.py index 93464f028a..1d0a14838b 100644 --- a/nova/tests/unit/test_utils.py +++ b/nova/tests/unit/test_utils.py @@ -995,6 +995,7 @@ class ValidateIntegerTestCase(test.NoDBTestCase): class ValidateNeutronConfiguration(test.NoDBTestCase): def test_nova_network(self): + self.flags(use_neutron=False) self.assertFalse(utils.is_neutron()) def test_neutron(self): diff --git a/nova/tests/unit/virt/hyperv/test_vmops.py b/nova/tests/unit/virt/hyperv/test_vmops.py index ae3aa189b5..78c666476f 100644 --- a/nova/tests/unit/virt/hyperv/test_vmops.py +++ b/nova/tests/unit/virt/hyperv/test_vmops.py @@ -390,7 +390,10 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase): @mock.patch('nova.virt.hyperv.vmops.VMOps._create_ephemerals') @mock.patch('nova.virt.hyperv.vmops.VMOps._create_root_device') @mock.patch('nova.virt.hyperv.vmops.VMOps._delete_disk_files') - def _test_spawn(self, mock_delete_disk_files, mock_create_root_device, + @mock.patch('nova.virt.hyperv.vmops.VMOps._get_neutron_events', + return_value=[]) + def _test_spawn(self, mock_get_neutron_events, + mock_delete_disk_files, mock_create_root_device, mock_create_ephemerals, mock_get_image_vm_gen, mock_create_instance, mock_save_device_metadata, mock_configdrive_required, @@ -437,6 +440,7 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase): fake_vm_gen) mock_create_ephemerals.assert_called_once_with( mock_instance, block_device_info['ephemerals']) + mock_get_neutron_events.assert_called_once_with(mock.sentinel.INFO) mock_get_image_vm_gen.assert_called_once_with(mock_instance.uuid, mock_image_meta) mock_create_instance.assert_called_once_with(