Skip to content

Commit

Permalink
Patch messagebus handling in diagnostic util tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Sep 20, 2024
1 parent 66e8237 commit 7cb12c2
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions test/test_diagnostic_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
import shutil
import sys
import unittest
from unittest.mock import patch

from ovos_utils.fakebus import FakeBus

import neon_utils.metrics_utils

from mock import Mock
Expand Down Expand Up @@ -62,7 +66,9 @@ def setUp(self) -> None:
self.report_metric.reset_mock()
neon_utils.metrics_utils.report_metric = self.report_metric

def test_send_diagnostics_default(self):
@patch("ovos_bus_client.util.get_mycroft_bus")
def test_send_diagnostics_default(self, get_bus):
get_bus.return_value = FakeBus()
from neon_core.util.diagnostic_utils import send_diagnostics
send_diagnostics()
self.report_metric.assert_called_once()
Expand All @@ -75,7 +81,9 @@ def test_send_diagnostics_default(self):
self.assertIsInstance(data["logs"], str)
# self.assertIsInstance(data["transcripts"], str)

def test_send_diagnostics_no_extras(self):
@patch("ovos_bus_client.util.get_mycroft_bus")
def test_send_diagnostics_no_extras(self, get_bus):
get_bus.return_value = FakeBus()
from neon_core.util.diagnostic_utils import send_diagnostics
send_diagnostics(False, False, False)
self.report_metric.assert_called_once()
Expand All @@ -88,7 +96,9 @@ def test_send_diagnostics_no_extras(self):
self.assertIsNone(data["logs"])
self.assertIsNone(data["transcripts"])

def test_send_diagnostics_allow_logs(self):
@patch("ovos_bus_client.util.get_mycroft_bus")
def test_send_diagnostics_allow_logs(self, get_bus):
get_bus.return_value = FakeBus()
from neon_core.util.diagnostic_utils import send_diagnostics
send_diagnostics(True, False, False)
self.report_metric.assert_called_once()
Expand All @@ -101,7 +111,9 @@ def test_send_diagnostics_allow_logs(self):
self.assertIsInstance(data["logs"], str)
self.assertIsNone(data["transcripts"])

def test_send_diagnostics_allow_transcripts(self):
@patch("ovos_bus_client.util.get_mycroft_bus")
def test_send_diagnostics_allow_transcripts(self, get_bus):
get_bus.return_value = FakeBus()
from neon_core.util.diagnostic_utils import send_diagnostics
send_diagnostics(False, True, False)
self.report_metric.assert_called_once()
Expand All @@ -114,7 +126,9 @@ def test_send_diagnostics_allow_transcripts(self):
self.assertIsNone(data["logs"])
# self.assertIsInstance(data["transcripts"], str)

def test_send_diagnostics_allow_config(self):
@patch("ovos_bus_client.util.get_mycroft_bus")
def test_send_diagnostics_allow_config(self, get_bus):
get_bus.return_value = FakeBus()
from neon_core.util.diagnostic_utils import send_diagnostics
send_diagnostics(False, False, True)
self.report_metric.assert_called_once()
Expand Down

0 comments on commit 7cb12c2

Please sign in to comment.