summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Simpson <tim.simpson@rackspace.com>2011-08-23 15:50:39 -0500
committerTim Simpson <tim.simpson@rackspace.com>2011-08-23 15:50:39 -0500
commitcbf8b3b36dde763164fcfd06e1d3c5732f57311d (patch)
treeca268af8c0d84f0d6f647f4d40aa7e4cd8607a41
parent83713359429263154cd4e0f8c9de0ee3f8f0636f (diff)
Fixed some pep8 and pylint issues.
-rw-r--r--nova/notifier/list_notifier.py7
-rw-r--r--nova/tests/notifier/test_list_notifier.py6
2 files changed, 10 insertions, 3 deletions
diff --git a/nova/notifier/list_notifier.py b/nova/notifier/list_notifier.py
index aa9c236b0..955ae1b57 100644
--- a/nova/notifier/list_notifier.py
+++ b/nova/notifier/list_notifier.py
@@ -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
diff --git a/nova/tests/notifier/test_list_notifier.py b/nova/tests/notifier/test_list_notifier.py
index ad2b039c5..b77720759 100644
--- a/nova/tests/notifier/test_list_notifier.py
+++ b/nova/tests/notifier/test_list_notifier.py
@@ -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):