From f6306967e693431c62296bcd0000371f34ba9b6a Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Thu, 25 Feb 2016 12:01:43 -0500 Subject: [PATCH] Tests: Don't assert on LOG.warn Lots of code can use LOG.warn, tests wanting to verify this should do a more robust check to ensure that specific text is logged or not logged. Change-Id: Id996ce761d90f1648f1f37c74a33df02d04cf3a3 Closes-bug: #1550102 --- .../netapp/dataontap/test_block_base.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_base.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_base.py index 17e3eab88..9d282cb56 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_base.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_base.py @@ -25,11 +25,12 @@ import copy import uuid import mock +from oslo_log import versionutils from oslo_utils import units import six from cinder import exception -from cinder.i18n import _ +from cinder.i18n import _, _LW from cinder import test from cinder.tests.unit.volume.drivers.netapp.dataontap import fakes as fake import cinder.tests.unit.volume.drivers.netapp.fakes as na_fakes @@ -57,24 +58,24 @@ class NetAppBlockStorageLibraryTestCase(test.TestCase): def get_config_base(self): return na_fakes.create_configuration() - def test_get_reserved_percentage_default_multipler(self): + @mock.patch.object(versionutils, 'report_deprecated_feature') + def test_get_reserved_percentage_default_multipler(self, mock_report): default = 1.2 reserved_percentage = 20.0 self.library.configuration.netapp_size_multiplier = default self.library.configuration.reserved_percentage = reserved_percentage - self.mock_object(block_base, 'LOG') result = self.library._get_reserved_percentage() self.assertEqual(reserved_percentage, result) - self.assertFalse(block_base.LOG.warn.called) + self.assertFalse(mock_report.called) - def test_get_reserved_percentage(self): + @mock.patch.object(versionutils, 'report_deprecated_feature') + def test_get_reserved_percentage(self, mock_report): multiplier = 2.0 self.library.configuration.netapp_size_multiplier = multiplier - self.mock_object(block_base, 'LOG') result = self.library._get_reserved_percentage() @@ -82,7 +83,11 @@ class NetAppBlockStorageLibraryTestCase(test.TestCase): reserved_percentage = 100 * int(reserved_ratio) self.assertEqual(reserved_percentage, result) - self.assertTrue(block_base.LOG.warn.called) + msg = _LW('The "netapp_size_multiplier" configuration option is ' + 'deprecated and will be removed in the Mitaka release. ' + 'Please set "reserved_percentage = %d" instead.') % ( + result) + mock_report.assert_called_once_with(block_base.LOG, msg) @mock.patch.object(block_base.NetAppBlockStorageLibrary, '_get_lun_attr', -- 2.45.2