mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-03 16:51:24 -07:00
TEST: field locking test fixes 2
Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
@@ -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()
|
conn.commit()
|
||||||
yield conn
|
yield conn
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ def test_set_empty_rejects_overwrite_on_non_empty_field():
|
|||||||
|
|
||||||
|
|
||||||
def test_empty_plugin_value_not_used():
|
def test_empty_plugin_value_not_used():
|
||||||
|
# Allows overwrite as new value same as old
|
||||||
result = can_overwrite_field(
|
result = can_overwrite_field(
|
||||||
field_name="devName",
|
field_name="devName",
|
||||||
current_value="",
|
current_value="",
|
||||||
@@ -138,7 +139,7 @@ def test_empty_plugin_value_not_used():
|
|||||||
plugin_settings={"set_always": [], "set_empty": []},
|
plugin_settings={"set_always": [], "set_empty": []},
|
||||||
field_value="",
|
field_value="",
|
||||||
)
|
)
|
||||||
assert result is False
|
assert result is True
|
||||||
|
|
||||||
|
|
||||||
def test_whitespace_only_plugin_value_not_used():
|
def test_whitespace_only_plugin_value_not_used():
|
||||||
|
|||||||
Reference in New Issue
Block a user