TEST: field locking test fixes 2

Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
jokob-sk
2026-01-29 07:52:34 +11:00
parent 8ac5b14403
commit 6eba0314fe
2 changed files with 23 additions and 1 deletions

View File

@@ -111,6 +111,27 @@ def scan_db():
"""
)
# Add the View logic provided
cur.execute("""
CREATE VIEW LatestDeviceScan AS
WITH RankedScans AS (
SELECT
c.*,
ROW_NUMBER() OVER (
PARTITION BY c.scanMac, c.scanSourcePlugin
ORDER BY c.scanLastConnection DESC
) AS rn
FROM CurrentScan c
)
SELECT
d.*,
r.*
FROM Devices d
LEFT JOIN RankedScans r
ON d.devMac = r.scanMac
WHERE r.rn = 1;
""")
conn.commit()
yield conn
conn.close()

View File

@@ -130,6 +130,7 @@ def test_set_empty_rejects_overwrite_on_non_empty_field():
def test_empty_plugin_value_not_used():
# Allows overwrite as new value same as old
result = can_overwrite_field(
field_name="devName",
current_value="",
@@ -138,7 +139,7 @@ def test_empty_plugin_value_not_used():
plugin_settings={"set_always": [], "set_empty": []},
field_value="",
)
assert result is False
assert result is True
def test_whitespace_only_plugin_value_not_used():