Fix database poison warnings, part 21

The following warning appears in the unit test logs a number of times.

    "UserWarning: This test uses methods that set internal oslo_db
state, but it does not claim to use the database. This will conflict
with the setup of tests that do use the database and cause failures
later."

This patch fixes all the warnings from:

    nova.tests.unit.compute.test_compute_api.py

Note that this warning is only emitted once per unit test worker, so new
offenders will show up in the logs each time you fix a test until they
are all gone.

Change-Id: I7bdf8422b050039df02c40a069964262dfe4a9eb
Related-Bug: #1568414
This commit is contained in:
Diana Clarke 2016-09-26 15:20:28 -04:00
parent 9adb28bfc5
commit 57672202e9
1 changed files with 4 additions and 1 deletions

View File

@ -1158,6 +1158,7 @@ class _ComputeAPIUnitTestMixIn(object):
self._test_delete('force_delete', vm_state=vm_state)
def test_delete_fast_if_host_not_set(self):
self.useFixture(fixtures.AllServicesCurrent())
inst = self._create_instance_obj()
inst.host = ''
quotas = quotas_obj.Quotas(self.context)
@ -3868,9 +3869,11 @@ class _ComputeAPIUnitTestMixIn(object):
self.assertEqual(swap_size, bdms[1].volume_size)
self.assertEqual(ephemeral_size, bdms[2].volume_size)
@mock.patch.object(objects.BuildRequestList, 'get_by_filters')
@mock.patch.object(compute_api.API, '_get_instances_by_filters')
@mock.patch.object(objects.CellMapping, 'get_by_uuid')
def test_tenant_to_project_conversion(self, mock_cell_map_get, mock_get):
def test_tenant_to_project_conversion(self, mock_cell_map_get, mock_get,
mock_buildreq_get):
mock_cell_map_get.side_effect = exception.CellMappingNotFound(
uuid='fake')
mock_get.return_value = objects.InstanceList(objects=[])