From cf281254478065a487fe502e52c1b3369f24f0ef Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Thu, 23 Jun 2016 16:19:30 +0200 Subject: [PATCH] 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 --- oslo_versionedobjects/fixture.py | 4 ++-- oslo_versionedobjects/tests/test_fixture.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/oslo_versionedobjects/fixture.py b/oslo_versionedobjects/fixture.py index 9c1925a..407b908 100644 --- a/oslo_versionedobjects/fixture.py +++ b/oslo_versionedobjects/fixture.py @@ -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()) diff --git a/oslo_versionedobjects/tests/test_fixture.py b/oslo_versionedobjects/tests/test_fixture.py index 46effce..bd564da 100644 --- a/oslo_versionedobjects/tests/test_fixture.py +++ b/oslo_versionedobjects/tests/test_fixture.py @@ -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