Fixed some pep8 and pylint issues.

This commit is contained in:
Tim Simpson 2011-08-23 15:50:39 -05:00
parent 8371335942
commit cbf8b3b36d
2 changed files with 10 additions and 3 deletions

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import sys
from nova import flags
from nova import log as logging
from nova import utils
@ -30,13 +28,14 @@ LOG = logging.getLogger('nova.notifier.list_notifier')
drivers = None
class ImportFailureNotifier(object):
"""Noisily re-raises some exception over-and-over when notify is called."""
def __init__(self, exception):
self.exception = exception
def notify(message):
def notify(self, message):
raise self.exception
@ -52,6 +51,7 @@ def _get_drivers():
drivers.append(ImportFailureNotifier(e))
return drivers
def notify(message):
"""Passes notification to mulitple notifiers in a list."""
for driver in _get_drivers():
@ -61,6 +61,7 @@ def notify(message):
LOG.exception(_("Problem '%(e)s' attempting to send to "
"notification driver %(driver)s." % locals()))
def _reset_drivers():
"""Used by unit tests to reset the drivers."""
global drivers

View File

@ -34,19 +34,25 @@ class NotifierListTestCase(test.TestCase):
list_notifier._reset_drivers()
self.stubs = stubout.StubOutForTesting()
# Mock log to add one to exception_count when log.exception is called
def mock_exception(cls, *args):
self.exception_count += 1
self.exception_count = 0
list_notifier_log = logging.getLogger('nova.notifier.list_notifier')
self.stubs.Set(list_notifier_log, "exception", mock_exception)
# Mock no_op notifier to add one to notify_count when called.
def mock_notify(cls, *args):
self.notify_count += 1
self.notify_count = 0
self.stubs.Set(nova.notifier.no_op_notifier, 'notify', mock_notify)
# Mock log_notifier to raise RuntimeError when called.
def mock_notify2(cls, *args):
raise RuntimeError("Bad notifier.")
self.stubs.Set(nova.notifier.log_notifier, 'notify', mock_notify2)
def tearDown(self):