Skip to content

Commit 7cb12c2

Browse files
committed
Patch messagebus handling in diagnostic util tests
1 parent 66e8237 commit 7cb12c2

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

test/test_diagnostic_utils.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
import shutil
3131
import sys
3232
import unittest
33+
from unittest.mock import patch
34+
35+
from ovos_utils.fakebus import FakeBus
36+
3337
import neon_utils.metrics_utils
3438

3539
from mock import Mock
@@ -62,7 +66,9 @@ def setUp(self) -> None:
6266
self.report_metric.reset_mock()
6367
neon_utils.metrics_utils.report_metric = self.report_metric
6468

65-
def test_send_diagnostics_default(self):
69+
@patch("ovos_bus_client.util.get_mycroft_bus")
70+
def test_send_diagnostics_default(self, get_bus):
71+
get_bus.return_value = FakeBus()
6672
from neon_core.util.diagnostic_utils import send_diagnostics
6773
send_diagnostics()
6874
self.report_metric.assert_called_once()
@@ -75,7 +81,9 @@ def test_send_diagnostics_default(self):
7581
self.assertIsInstance(data["logs"], str)
7682
# self.assertIsInstance(data["transcripts"], str)
7783

78-
def test_send_diagnostics_no_extras(self):
84+
@patch("ovos_bus_client.util.get_mycroft_bus")
85+
def test_send_diagnostics_no_extras(self, get_bus):
86+
get_bus.return_value = FakeBus()
7987
from neon_core.util.diagnostic_utils import send_diagnostics
8088
send_diagnostics(False, False, False)
8189
self.report_metric.assert_called_once()
@@ -88,7 +96,9 @@ def test_send_diagnostics_no_extras(self):
8896
self.assertIsNone(data["logs"])
8997
self.assertIsNone(data["transcripts"])
9098

91-
def test_send_diagnostics_allow_logs(self):
99+
@patch("ovos_bus_client.util.get_mycroft_bus")
100+
def test_send_diagnostics_allow_logs(self, get_bus):
101+
get_bus.return_value = FakeBus()
92102
from neon_core.util.diagnostic_utils import send_diagnostics
93103
send_diagnostics(True, False, False)
94104
self.report_metric.assert_called_once()
@@ -101,7 +111,9 @@ def test_send_diagnostics_allow_logs(self):
101111
self.assertIsInstance(data["logs"], str)
102112
self.assertIsNone(data["transcripts"])
103113

104-
def test_send_diagnostics_allow_transcripts(self):
114+
@patch("ovos_bus_client.util.get_mycroft_bus")
115+
def test_send_diagnostics_allow_transcripts(self, get_bus):
116+
get_bus.return_value = FakeBus()
105117
from neon_core.util.diagnostic_utils import send_diagnostics
106118
send_diagnostics(False, True, False)
107119
self.report_metric.assert_called_once()
@@ -114,7 +126,9 @@ def test_send_diagnostics_allow_transcripts(self):
114126
self.assertIsNone(data["logs"])
115127
# self.assertIsInstance(data["transcripts"], str)
116128

117-
def test_send_diagnostics_allow_config(self):
129+
@patch("ovos_bus_client.util.get_mycroft_bus")
130+
def test_send_diagnostics_allow_config(self, get_bus):
131+
get_bus.return_value = FakeBus()
118132
from neon_core.util.diagnostic_utils import send_diagnostics
119133
send_diagnostics(False, False, True)
120134
self.report_metric.assert_called_once()

0 commit comments

Comments
 (0)