placement: correct improper test case inheritance

nova/tests/unit/scheduler/client/test_report.py had a bunch of tests in
a base test class instead of just the setUp(). This resulted in
re-running a whole bunch of tests unnecessarily.

Before:

Ran: 61 tests in 35.0000 sec.
- Passed: 61
- Skipped: 0
- Expected Fail: 0
- Unexpected Success: 0
- Failed: 0
Sum of execute time for each test: 11.8261 sec.

after:

Ran: 35 tests in 35.0000 sec.
- Passed: 35
- Skipped: 0
- Expected Fail: 0
- Unexpected Success: 0
- Failed: 0
Sum of execute time for each test: 5.0003 sec.

Same test content and coverage, just not re-running tests unnecessarily.

Change-Id: Icbdf8dd4e221259fd4a2683cb12cc26dc87733bd
This commit is contained in:
Jay Pipes 2016-12-02 16:05:52 -05:00
parent e4f6689cb5
commit 1870c75c45
1 changed files with 15 additions and 10 deletions

View File

@ -92,6 +92,16 @@ class SafeConnectedTestCase(test.NoDBTestCase):
self.assertTrue(req.called)
class TestConstructor(test.NoDBTestCase):
@mock.patch('keystoneauth1.session.Session')
@mock.patch('keystoneauth1.loading.load_auth_from_conf_options')
def test_constructor(self, load_auth_mock, ks_sess_mock):
report.SchedulerReportClient()
load_auth_mock.assert_called_once_with(CONF, 'placement')
ks_sess_mock.assert_called_once_with(auth=load_auth_mock.return_value)
class SchedulerReportClientTestCase(test.NoDBTestCase):
def setUp(self):
@ -116,14 +126,8 @@ class SchedulerReportClientTestCase(test.NoDBTestCase):
) as (_auth_mock, _sess_mock):
self.client = report.SchedulerReportClient()
@mock.patch('keystoneauth1.session.Session')
@mock.patch('keystoneauth1.loading.load_auth_from_conf_options')
def test_constructor(self, load_auth_mock, ks_sess_mock):
report.SchedulerReportClient()
load_auth_mock.assert_called_once_with(CONF, 'placement')
ks_sess_mock.assert_called_once_with(auth=load_auth_mock.return_value)
class TestProviderOperations(SchedulerReportClientTestCase):
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'
'_create_resource_provider')
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'
@ -359,6 +363,8 @@ class SchedulerReportClientTestCase(test.NoDBTestCase):
self.assertTrue(logging_mock.called)
self.assertFalse(result)
class TestComputeNodeToInventoryDict(test.NoDBTestCase):
def test_compute_node_inventory(self):
uuid = uuids.compute_node
name = 'computehost'
@ -404,6 +410,8 @@ class SchedulerReportClientTestCase(test.NoDBTestCase):
}
self.assertEqual(expected, result)
class TestInventory(SchedulerReportClientTestCase):
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'
'_ensure_resource_provider')
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'
@ -416,9 +424,6 @@ class SchedulerReportClientTestCase(test.NoDBTestCase):
mock_erp.assert_called_once_with(cn.uuid, cn.hypervisor_hostname)
self.assertFalse(mock_ui.called)
class TestInventory(SchedulerReportClientTestCase):
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'
'get')
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'