mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-10-02 10:45:05 -04:00
Fix DOCKERDISC_HOST_MAC docs and strengthen case-insensitivity test
resolve_host_mac() returns the manually configured MAC immediately, with no Socket Proxy /info call at all - the config.json text still described it as a fallback used only when auto-detection fails. Reworded both the setting's own description and the parent "Docker hosts" description to match actual behavior. The case-insensitivity regression test for lookup_device_mac() stubbed DeviceInstance.getByMac() to return a fixed row regardless of input, so it passed even without exercising real collation - functionally a duplicate of test_lookup_device_mac_found. Replaced it with a delegation check, and added real SQLite-backed coverage for DeviceInstance.getByMac()'s case-insensitivity in test/backend/test_device_instance.py. That surfaced a gap in the shared db_test_helpers.py fixture: its Devices.devMac column was missing the COLLATE NOCASE that the real schema declares, so it could not have exercised this behavior. Fixed the fixture to match. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011meLPKCzVpdZyAUfv5U6mm
This commit is contained in:
1 parent
d512e5d84e
commit
091e648e88
4 files changed
+48
-18
No files matched your search
@@ -445,20 +445,18 @@ def test_lookup_device_mac_not_found():
|
||||
assert dockerdisc.lookup_device_mac("aa:bb:cc:dd:ee:ff") is False
|
||||
|
||||
|
||||
def test_lookup_device_mac_found_regardless_of_stored_mac_case():
|
||||
"""The plugin always passes a lowercase, normalize_mac()'d value in -
|
||||
this only guards that lookup_device_mac() doesn't do anything of its
|
||||
own (e.g. an exact-string comparison) that would undo whatever
|
||||
case-insensitivity DeviceInstance.getByMac() provides. The real
|
||||
guarantee is schema-level - Devices.devMac is declared
|
||||
`COLLATE NOCASE` (server/db/schema/app.sql), which is exactly why
|
||||
getByMac() itself doesn't need to apply it explicitly (unlike
|
||||
getAllByName(), which does - devName has no such column collation;
|
||||
see that method's docstring and test/backend/test_device_instance.py).
|
||||
This test's stub can't exercise real SQLite collation, only that this
|
||||
function's own logic is agnostic to it."""
|
||||
with patch.object(dockerdisc, "DeviceInstance", _stub_device_instance(get_by_mac={"devMac": "AA:BB:CC:DD:EE:FF"})):
|
||||
assert dockerdisc.lookup_device_mac("aa:bb:cc:dd:ee:ff") is True
|
||||
def test_lookup_device_mac_passes_mac_through_unchanged():
|
||||
"""lookup_device_mac() must not do any of its own case massaging - it
|
||||
delegates entirely to DeviceInstance.getByMac(), which relies on
|
||||
Devices.devMac's schema-level `COLLATE NOCASE` (server/db/schema/app.sql)
|
||||
for case-insensitive matching. That guarantee is exercised against a
|
||||
real SQLite connection in test/backend/test_device_instance.py's
|
||||
TestGetByMac; a mocked DeviceInstance can't exercise real collation, so
|
||||
this test only checks that the mac argument reaches getByMac() as-is."""
|
||||
stub = _stub_device_instance(get_by_mac={"devMac": "aa:bb:cc:dd:ee:ff"})
|
||||
with patch.object(dockerdisc, "DeviceInstance", stub):
|
||||
dockerdisc.lookup_device_mac("AA:BB:CC:DD:EE:FF")
|
||||
stub.return_value.getByMac.assert_called_once_with("AA:BB:CC:DD:EE:FF")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user