Extend test_hashes to allow extra info gathering

ObjectVersionChecker.get_hashes() already support extra data collection
for fingerprint generation via the extra_data_func parameter.
However this cannot be used from test_hashes().

Nova versioned notification work depends on this extra data gathering
support. See nova bug #1595575

Change-Id: I7f4d0f37e638de6fcef7211280cedd7d1f09ab74
Closes-Bug: #1595552
This commit is contained in:
Balazs Gibizer 2016-06-23 16:19:30 +02:00
parent 0bb46f0a2c
commit cf28125447
2 changed files with 12 additions and 2 deletions

View File

@ -265,8 +265,8 @@ class ObjectVersionChecker(object):
obj_name, extra_data_func=extra_data_func)
return fingerprints
def test_hashes(self, expected_hashes):
fingerprints = self.get_hashes()
def test_hashes(self, expected_hashes, extra_data_func=None):
fingerprints = self.get_hashes(extra_data_func=extra_data_func)
stored = set(expected_hashes.items())
computed = set(fingerprints.items())

View File

@ -322,6 +322,16 @@ class TestObjectVersionChecker(test.TestCase):
"should contain the updated object with the new "
"hash.")
def test_test_hashes_passes_extra_func(self):
# Make sure that test_hashes passes the extra_func to get_hashes
mock_extra_func = mock.Mock()
with mock.patch.object(self.ovc, 'get_hashes') as mock_get_hashes:
self.ovc.test_hashes({}, extra_data_func=mock_extra_func)
mock_get_hashes.assert_called_once_with(
extra_data_func=mock_extra_func)
def test_get_dependency_tree(self):
# Make sure get_dependency_tree() gets the dependencies of all
# objects in the registry