Exemple #1
0
    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)
Exemple #2
0
    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)
Exemple #3
0
    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)