Commit Graph
22 Commits
Author SHA1 Message Date
hemna aa43f60728 fix: add reset() to @singleton decorator to allow test isolation (#262)
The @singleton decorator stored its instance in wrapper_singleton.instance
inside a closure. Tests could reset __new__-based singletons via
ClassName._instance = None, but @singleton classes had no equivalent reset
mechanism, causing state to leak between tests.

Add wrapper_singleton.reset() to every @singleton-decorated class. The
method clears wrapper_singleton.instance so the next call creates a fresh
instance, matching the __new__ singleton pattern.

Update all tests to call ClassName.reset() instead of manually setting
ClassName.instance = None (tests/client/test_client.py x5,
tests/client/test_registry.py x1).

Tests added (tests/utils/test_utils.py):
- test_singleton_has_reset: asserts reset is callable on the wrapper
- test_singleton_reset_clears_instance: verifies a new instance is created
  after reset(), not the cached one
- test_singleton_instance_is_none_before_first_call: verifies the instance
  lifecycle — None → populated → None after reset

Closes #240
2026-08-28 13:51:33 -04:00
hemna 3f505b6043 test: add unit tests for APRSDClient._checks initialisation (#238 follow-up) (#257)
- test_checks_initialised_to_false: asserts _checks is False right after
  __init__, catching any regression that removes the initialisation
- test_keepalive_check_first_call_no_reset: verifies no AttributeError and
  no spurious reset on the very first keepalive_check() call even when the
  driver is already dead
- test_keepalive_check: remove the manual _checks = False setup that masked
  the original bug; rely on the __init__ value instead
2026-08-28 12:28:42 -04:00
hemna 4ea9e33e20 fix: APRSISDriver.is_configured() returns False when driver is disabled (#236)
The final `return True` in is_configured() should be `return False`.
When APRS-IS is not enabled, the method always returned True, so the
startup guard in server.py never fired for misconfigured instances.

Closes #2
2026-08-28 12:10:50 -04:00
hemna 314f4da180 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.
2026-03-27 10:18:07 -04:00
hemna f6eb383caf fix: Update test to work with singleton pattern
The APRSISDriver uses @singleton decorator which transforms the class
into a function. The test was incorrectly trying to use __new__ which
doesn't work with decorated singletons. Instead, re-initialize the
existing instance after changing the config.
2026-03-27 10:13:55 -04:00
hemna 930339d4cf feat: Add configurable stale_timeout for APRS-IS connections
Add a new 'stale_timeout' configuration option to the aprs_network config
group that allows users to customize how long to wait before considering
an APRS-IS connection stale.

Problem:
The stale connection threshold was hardcoded to 2 minutes. In environments
with frequent network hiccups or when using certain APRS-IS servers that
may drop connections silently, 2 minutes can be too long to wait before
reconnecting, resulting in significant data loss.

Solution:
- Add 'stale_timeout' option to aprsd/conf/client.py with default of 120s
- Update APRSISDriver.__init__ to use the config value
- Maintain backward compatibility by defaulting to 120s if not configured
- Update tests to handle the new configuration option

Usage:
  [aprs_network]
  stale_timeout = 60  # Reconnect after 60 seconds without data

The default remains 120 seconds (2 minutes) for backward compatibility.
2026-03-27 10:05:44 -04:00
hemna 6ea9889369 make consumer call signature consistent. 2026-02-18 14:11:25 -05:00
hemna 2b7e42802b update the keepalive for kiss 2026-02-18 14:00:52 -05:00
hemna 3bcd03a514 Fix client / driver inconsistencies from protocol
The client registry defined a protocol that all drivers had
to implement.  This patch ensures that all methods are
consistent in the protocol definition.
2026-01-23 09:18:35 -05:00
hemna cc8d834e5c Remove the login callsign in aprs_network
It's been confusing for a while that when we configured aprsd,
we had to enter the callsign in the [DEFAULT] section and
the [aprs_network] section.

This patch removes the login from the aprs_network section.  aprsd
will now use the main callsign in the [DEFAULT] section as the callsign
to login to the aprsis network.
2026-01-18 21:21:09 -05:00
hemna 6cbd6452d5 kiss consumer update
this patch updates the kiss consumer to call the callback with the frame
as arg[0] just like aprslib does.
2026-01-12 23:25:06 -05:00
hemna d0dfaa42e6 Added unit tests 2025-12-09 17:20:23 -05:00
hemna c34a82108b fixed tox failures 2025-11-26 20:28:25 -05:00
hemna 961d3e946a Fixed unit tests 2025-10-11 20:23:44 -04:00
hemna af0feaf9c8 Fixed some unit tests
Fixed unit tests related to the updated static method signatures
of the client and drivers.
2025-10-07 14:18:50 -04:00
hemna 1c39546bb9 Reworked the entire client and drivers
This patch includes a completely reworked client structure.
There is now only 1 client object, that loads the appropriate
drivers.  The drivers are fake, aprsis and tcpkiss.

The TCPKISS client was written from scratch to avoid using asyncio.
Asyncion is nothing but a pain in the ass.
2025-04-23 20:52:02 -04:00
hemna 72d068c0b8 Changed to ruff
This patch changes to the ruff linter.  SO MUCH quicker.
Removed grey and mypy as well.
2024-12-20 22:00:54 -05:00
hemna f66b96288f Fixed issue with packet object and prepare()
If any part of the code had a packet object and called prepare()
on it, it would create a msgNo if it wasn't set.  Sometimes we
get packets on the wire/RF that don't have a msgNo, so adding one
locally is wrong.   We should ONLY create a msgNo on a packet that
is destined for transmission.

This patch ensures that even if prepare() is called, that only
packets that are created locally for TX get a msgNo unless it
already exists from RX'd packets.
2024-11-26 16:52:39 -05:00
hemna c82e9ba597 Fixed broken unit tests
This patch fixes some broken unit tests with the aprsis client.
2024-11-21 09:01:49 -05:00
hemna 224686cac5 Added unit test for APRSISClient 2024-11-05 13:39:44 -05:00
hemna ab2de86726 Added unit test for ClientFactory 2024-11-05 12:32:16 -05:00
hemna f1d066b8a9 Added unit test for client base
This patch adds a unit test for the APRSClient base class.
2024-11-05 12:15:59 -05:00