From e649bcfe2558ba55ab360f25a45d0e70eb252102 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Thu, 29 Jan 2026 08:42:29 +1100 Subject: [PATCH] TEST: field locking test fixes 4 Signed-off-by: jokob-sk --- .../test_ip_format_and_locking.py | 21 +++++++++++++++++++ .../test_ip_update_logic.py | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/test/authoritative_fields/test_ip_format_and_locking.py b/test/authoritative_fields/test_ip_format_and_locking.py index 1b41f0da..690cfc2a 100644 --- a/test/authoritative_fields/test_ip_format_and_locking.py +++ b/test/authoritative_fields/test_ip_format_and_locking.py @@ -68,6 +68,27 @@ def ip_test_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_ip_update_logic.py b/test/authoritative_fields/test_ip_update_logic.py index 5096534c..c735c17b 100644 --- a/test/authoritative_fields/test_ip_update_logic.py +++ b/test/authoritative_fields/test_ip_update_logic.py @@ -59,6 +59,27 @@ def in_memory_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()