|
| 1 | +import warnings |
1 | 2 | from unittest import TestCase
|
2 | 3 | from unittest.mock import patch
|
3 | 4 |
|
|
8 | 9 |
|
9 | 10 |
|
10 | 11 | class TestDistro(TestCase):
|
| 12 | + @patch("azure.monitor.opentelemetry.autoinstrumentation._distro._is_attach_enabled", return_value=True) |
11 | 13 | @patch("azure.monitor.opentelemetry.autoinstrumentation._distro.settings")
|
12 | 14 | @patch(
|
13 | 15 | "azure.monitor.opentelemetry.autoinstrumentation._distro.AzureDiagnosticLogging.enable"
|
14 | 16 | )
|
15 |
| - def test_configure(self, mock_diagnostics, azure_core_mock): |
| 17 | + def test_configure(self, mock_diagnostics, azure_core_mock, attach_mock): |
16 | 18 | distro = AzureMonitorDistro()
|
17 |
| - distro.configure() |
| 19 | + with warnings.catch_warnings(): |
| 20 | + warnings.simplefilter("error") |
| 21 | + distro.configure() |
| 22 | + self.assertEqual(mock_diagnostics.call_count, 2) |
| 23 | + self.assertEqual( |
| 24 | + azure_core_mock.tracing_implementation, OpenTelemetrySpan |
| 25 | + ) |
| 26 | + |
| 27 | + @patch("azure.monitor.opentelemetry.autoinstrumentation._distro._is_attach_enabled", return_value=False) |
| 28 | + @patch("azure.monitor.opentelemetry.autoinstrumentation._distro.settings") |
| 29 | + @patch( |
| 30 | + "azure.monitor.opentelemetry.autoinstrumentation._distro.AzureDiagnosticLogging.enable" |
| 31 | + ) |
| 32 | + def test_configure_preview(self, mock_diagnostics, azure_core_mock, attach_mock): |
| 33 | + distro = AzureMonitorDistro() |
| 34 | + with self.assertWarns(Warning): |
| 35 | + distro.configure() |
18 | 36 | self.assertEqual(mock_diagnostics.call_count, 2)
|
19 | 37 | self.assertEqual(
|
20 | 38 | azure_core_mock.tracing_implementation, OpenTelemetrySpan
|
|
0 commit comments