def test_constructor(self): patch_worker = mock.patch( 'opencensus.trace.exporters.transports.background_thread._Worker', autospec=True) exporter = mock.Mock() with patch_worker: transport = background_thread.BackgroundThreadTransport(exporter) self.assertTrue(transport.worker.start.called) self.assertEqual(transport.exporter, exporter)
def test_flush(self): patch_worker = mock.patch( 'opencensus.trace.exporters.transports.background_thread._Worker', autospec=True) exporter = mock.Mock() with patch_worker: transport = background_thread.BackgroundThreadTransport(exporter) transport.flush() self.assertTrue(transport.worker.flush.called)
def test_export(self): patch_worker = mock.patch( 'opencensus.trace.exporters.transports.background_thread._Worker', autospec=True) exporter = mock.Mock() with patch_worker: transport = background_thread.BackgroundThreadTransport(exporter) trace = { 'traceId': 'test', 'spans': [{}, {}], } transport.export(trace) self.assertTrue(transport.worker.enqueue.called)