yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #66078
[Bug 1706399] [NEW] unit test 'test_get_volume_config' doesn't test anything useful
Public bug reported:
Description
===========
The unit test `test_get_volume_config` [1] asserts that a mock is equal
to itself:
@mock.patch.object(volume_drivers.LibvirtFakeVolumeDriver,
'connect_volume')
@mock.patch.object(volume_drivers.LibvirtFakeVolumeDriver, 'get_config')
def test_get_volume_config(self, get_config, connect_volume):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
connection_info = {'driver_volume_type': 'fake',
'data': {'device_path': '/fake',
'access_mode': 'rw'}}
bdm = {'device_name': 'vdb',
'disk_bus': 'fake-bus',
'device_type': 'fake-type'}
disk_info = {'bus': bdm['disk_bus'], 'type': bdm['device_type'],
'dev': 'vdb'}
mock_config = mock.MagicMock()
get_config.return_value = mock_config
config = drvr._get_volume_config(connection_info, disk_info)
get_config.assert_called_once_with(connection_info, disk_info)
self.assertEqual(mock_config, config)
self.assertEqual(mock_config, config)
Steps to reproduce
==================
$ .tox/py27/bin/python -m testtools.run nova.tests.unit.virt.libvirt.test_driver.LibvirtConnTestCase.test_get_volume_config
Add these two lines to see that the objects are the same:
print("mock config: %s" % mock_config)
print("config: %s" % config)
Expected result
===============
The `mock_config` has some kind of recording how it should look like and
the created `config` object is tested against that.
Actual result
=============
`mock_config` and `config` are the very same python object.
$ .tox/py27/bin/python -m testtools.run nova.tests.unit.virt.libvirt.test_driver.LibvirtConnTestCase.test_get_volume_config
Tests running...
mock config: <MagicMock id='147674384'>
config: <MagicMock id='147674384'>
Environment
===========
$ git log --oneline -1
87a0143 Merge "[placement] Flush RC_CACHE after each gabbit sequence"
References:
===========
[1] https://github.com/openstack/nova/blob/bbe0f313bdfd30cc1c740709543b679567b42f0f/nova/tests/unit/virt/libvirt/test_driver.py#L6355-L6373
** Affects: nova
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1706399
Title:
unit test 'test_get_volume_config' doesn't test anything useful
Status in OpenStack Compute (nova):
New
Bug description:
Description
===========
The unit test `test_get_volume_config` [1] asserts that a mock is equal
to itself:
@mock.patch.object(volume_drivers.LibvirtFakeVolumeDriver,
'connect_volume')
@mock.patch.object(volume_drivers.LibvirtFakeVolumeDriver, 'get_config')
def test_get_volume_config(self, get_config, connect_volume):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
connection_info = {'driver_volume_type': 'fake',
'data': {'device_path': '/fake',
'access_mode': 'rw'}}
bdm = {'device_name': 'vdb',
'disk_bus': 'fake-bus',
'device_type': 'fake-type'}
disk_info = {'bus': bdm['disk_bus'], 'type': bdm['device_type'],
'dev': 'vdb'}
mock_config = mock.MagicMock()
get_config.return_value = mock_config
config = drvr._get_volume_config(connection_info, disk_info)
get_config.assert_called_once_with(connection_info, disk_info)
self.assertEqual(mock_config, config)
self.assertEqual(mock_config, config)
Steps to reproduce
==================
$ .tox/py27/bin/python -m testtools.run nova.tests.unit.virt.libvirt.test_driver.LibvirtConnTestCase.test_get_volume_config
Add these two lines to see that the objects are the same:
print("mock config: %s" % mock_config)
print("config: %s" % config)
Expected result
===============
The `mock_config` has some kind of recording how it should look like and
the created `config` object is tested against that.
Actual result
=============
`mock_config` and `config` are the very same python object.
$ .tox/py27/bin/python -m testtools.run nova.tests.unit.virt.libvirt.test_driver.LibvirtConnTestCase.test_get_volume_config
Tests running...
mock config: <MagicMock id='147674384'>
config: <MagicMock id='147674384'>
Environment
===========
$ git log --oneline -1
87a0143 Merge "[placement] Flush RC_CACHE after each gabbit sequence"
References:
===========
[1] https://github.com/openstack/nova/blob/bbe0f313bdfd30cc1c740709543b679567b42f0f/nova/tests/unit/virt/libvirt/test_driver.py#L6355-L6373
To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1706399/+subscriptions
Follow ups