def __init__(self): from heka.streams import DebugCaptureStream from heka.encoders import JSONEncoder self.stream = DebugCaptureStream() self.encoder = JSONEncoder()
class DebugCaptureSender(object): def __init__(self): from heka.streams import DebugCaptureStream from heka.encoders import JSONEncoder self.stream = DebugCaptureStream() self.encoder = JSONEncoder() def send_message(self, msg): self.stream.write(self.encoder.encode(msg)) def __getattr__(self, key): return getattr(self.stream, key)
def setUp(self): self.stream = DebugCaptureStream() self.client = HekaClient(self.stream, self.logger) # overwrite the class-wide threadlocal w/ an instance one # so values won't persist btn tests self.timer_ob = self.client.timer(self.timer_name) self.timer_ob.__dict__['_local'] = threading.local()
def setUp(self): self.mock_stream = DebugCaptureStream() class NoEncoder(object): def __init__(self, hmc): pass def encode(self, msg): return msg self.client = HekaClient(self.mock_stream, self.logger, encoder=NoEncoder) # overwrite the class-wide threadlocal w/ an instance one # so values won't persist btn tests self.timer_ob = self.client.timer(self.timer_name) self.timer_ob.__dict__['_local'] = threading.local()
def setup_heka(cls): # Clobber the stream with a debug version cls.heka_client = configure_heka() cls.heka_client.stream = DebugCaptureStream() cls.heka_client.encoder = NullEncoder(None)
def setUp(self): self.stream = DebugCaptureStream() self.client = HekaClient(self.stream, self.logger)