31 lines
707 B
Python
31 lines
707 B
Python
import json
|
|
import logging
|
|
|
|
|
|
class FakeJob(object):
|
|
def __init__(self, data):
|
|
"""
|
|
data: JSON object to convert to a string
|
|
"""
|
|
self.data = json.dumps(data)
|
|
|
|
|
|
class MockLoggingHandler(logging.Handler):
|
|
"""Mock logging handler to check for expected logs."""
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
self.reset()
|
|
logging.Handler.__init__(self, *args, **kwargs)
|
|
|
|
def emit(self, record):
|
|
self.messages[record.levelname.lower()].append(record.getMessage())
|
|
|
|
def reset(self):
|
|
self.messages = {
|
|
'debug': [],
|
|
'info': [],
|
|
'warning': [],
|
|
'error': [],
|
|
'critical': [],
|
|
}
|