Skip to content

Commit

Permalink
Fix sonarqube
Browse files Browse the repository at this point in the history
  • Loading branch information
jmthomas committed Feb 18, 2025
1 parent 06bebb1 commit c21fe82
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions openc3/python/test/microservices/test_decom_microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import threading
from unittest.mock import patch
from datetime import datetime, timezone
from test.test_helper import *
from test.test_helper import Mock, mock_redis, setup_system, capture_io
from openc3.api.tlm_api import tlm
from openc3.system.system import System
from openc3.packets.limits_response import LimitsResponse
Expand Down Expand Up @@ -170,24 +170,23 @@ def test_handles_exceptions_in_user_processors(self):

def test_handles_limits_responses_in_another_thread(self):
class DelayedLimitsResponse(LimitsResponse):
def call(packet, item, old_limits_state):
def call(self, packet, item, old_limits_state):
time.sleep(0.1)

packet = System.telemetry.packet("INST", "HEALTH_STATUS")
temp1 = packet.get_item("TEMP1")
temp1.limits.response = DelayedLimitsResponse()
packet.received_time = datetime.now(timezone.utc)
for stdout in capture_io():
TelemetryTopic.write_packet(packet, scope="DEFAULT")
time.sleep(0.01)
TelemetryTopic.write_packet(packet, scope="DEFAULT")
time.sleep(0.01)

# Verify that even though the limits response sleeps for 0.1s, the decom thread is not blocked
self.assertLess(self.dm.metric.data["decom_duration_seconds"]["value"], 0.01)

def test_handles_exceptions_in_limits_responses(self):
class BadLimitsResponse(LimitsResponse):
def call(self, packet, item, old_limits_state):
raise Exception("Bad response")
raise RuntimeError("Bad response")

packet = System.telemetry.packet("INST", "HEALTH_STATUS")
temp1 = packet.get_item("TEMP1")
Expand Down

0 comments on commit c21fe82

Please sign in to comment.