1
0
mirror of https://github.com/craigerl/aprsd.git synced 2026-03-31 12:15:34 -04:00

fix: Restore max_delta after custom stale_timeout test

The singleton's max_delta was being modified by test_init_custom_stale_timeout
and not restored, causing test_is_stale_connection_false to fail because
it expected 2 minutes but got 60 seconds.
This commit is contained in:
Walter Boring 2026-03-27 10:18:07 -04:00
parent f6eb383caf
commit 314f4da180

View File

@ -80,14 +80,22 @@ class TestAPRSISDriver(unittest.TestCase):
def test_init_custom_stale_timeout(self):
"""Test initialization with custom stale_timeout."""
# Set a custom stale_timeout
self.mock_conf.aprs_network.stale_timeout = 60 # 1 minute
# Save original max_delta
original_max_delta = self.driver.max_delta
# Re-initialize the existing driver with new config
# (singleton pattern means we can't create a new instance)
self.driver.__init__()
try:
# Set a custom stale_timeout
self.mock_conf.aprs_network.stale_timeout = 60 # 1 minute
self.assertEqual(self.driver.max_delta, datetime.timedelta(seconds=60))
# Re-initialize the existing driver with new config
# (singleton pattern means we can't create a new instance)
self.driver.__init__()
self.assertEqual(self.driver.max_delta, datetime.timedelta(seconds=60))
finally:
# Restore original max_delta so other tests aren't affected
self.driver.max_delta = original_max_delta
self.mock_conf.aprs_network.stale_timeout = 120
def test_is_enabled_true(self):
"""Test is_enabled returns True when APRS-IS is enabled."""