30
30
import shutil
31
31
import sys
32
32
import unittest
33
+ from unittest .mock import patch
34
+
35
+ from ovos_utils .fakebus import FakeBus
36
+
33
37
import neon_utils .metrics_utils
34
38
35
39
from mock import Mock
@@ -62,7 +66,9 @@ def setUp(self) -> None:
62
66
self .report_metric .reset_mock ()
63
67
neon_utils .metrics_utils .report_metric = self .report_metric
64
68
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 ()
66
72
from neon_core .util .diagnostic_utils import send_diagnostics
67
73
send_diagnostics ()
68
74
self .report_metric .assert_called_once ()
@@ -75,7 +81,9 @@ def test_send_diagnostics_default(self):
75
81
self .assertIsInstance (data ["logs" ], str )
76
82
# self.assertIsInstance(data["transcripts"], str)
77
83
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 ()
79
87
from neon_core .util .diagnostic_utils import send_diagnostics
80
88
send_diagnostics (False , False , False )
81
89
self .report_metric .assert_called_once ()
@@ -88,7 +96,9 @@ def test_send_diagnostics_no_extras(self):
88
96
self .assertIsNone (data ["logs" ])
89
97
self .assertIsNone (data ["transcripts" ])
90
98
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 ()
92
102
from neon_core .util .diagnostic_utils import send_diagnostics
93
103
send_diagnostics (True , False , False )
94
104
self .report_metric .assert_called_once ()
@@ -101,7 +111,9 @@ def test_send_diagnostics_allow_logs(self):
101
111
self .assertIsInstance (data ["logs" ], str )
102
112
self .assertIsNone (data ["transcripts" ])
103
113
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 ()
105
117
from neon_core .util .diagnostic_utils import send_diagnostics
106
118
send_diagnostics (False , True , False )
107
119
self .report_metric .assert_called_once ()
@@ -114,7 +126,9 @@ def test_send_diagnostics_allow_transcripts(self):
114
126
self .assertIsNone (data ["logs" ])
115
127
# self.assertIsInstance(data["transcripts"], str)
116
128
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 ()
118
132
from neon_core .util .diagnostic_utils import send_diagnostics
119
133
send_diagnostics (False , False , True )
120
134
self .report_metric .assert_called_once ()
0 commit comments