diff --git a/test/authoritative_fields/test_field_lock_scan_integration.py b/test/authoritative_fields/test_field_lock_scan_integration.py index 25fa57b5..09ce5237 100644 --- a/test/authoritative_fields/test_field_lock_scan_integration.py +++ b/test/authoritative_fields/test_field_lock_scan_integration.py @@ -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() diff --git a/test/authoritative_fields/test_field_lock_scenarios.py b/test/authoritative_fields/test_field_lock_scenarios.py index d154cf89..e81403c5 100644 --- a/test/authoritative_fields/test_field_lock_scenarios.py +++ b/test/authoritative_fields/test_field_lock_scenarios.py @@ -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():