Skip to content

Commit 6eba031

Browse files
committed
TEST: field locking test fixes 2
Signed-off-by: jokob-sk <jokob.sk@gmail.com>
1 parent 8ac5b14 commit 6eba031

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎test/authoritative_fields/test_field_lock_scan_integration.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,27 @@ def scan_db():
111111
"""
112112
)
113113

114+
# Add the View logic provided
115+
cur.execute("""
116+
CREATE VIEW LatestDeviceScan AS
117+
WITH RankedScans AS (
118+
SELECT
119+
c.*,
120+
ROW_NUMBER() OVER (
121+
PARTITION BY c.scanMac, c.scanSourcePlugin
122+
ORDER BY c.scanLastConnection DESC
123+
) AS rn
124+
FROM CurrentScan c
125+
)
126+
SELECT
127+
d.*,
128+
r.*
129+
FROM Devices d
130+
LEFT JOIN RankedScans r
131+
ON d.devMac = r.scanMac
132+
WHERE r.rn = 1;
133+
""")
134+
114135
conn.commit()
115136
yield conn
116137
conn.close()

‎test/authoritative_fields/test_field_lock_scenarios.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def test_set_empty_rejects_overwrite_on_non_empty_field():
130130

131131

132132
def test_empty_plugin_value_not_used():
133+
# Allows overwrite as new value same as old
133134
result = can_overwrite_field(
134135
field_name="devName",
135136
current_value="",
@@ -138,7 +139,7 @@ def test_empty_plugin_value_not_used():
138139
plugin_settings={"set_always": [], "set_empty": []},
139140
field_value="",
140141
)
141-
assert result is False
142+
assert result is True
142143

143144

144145
def test_whitespace_only_plugin_value_not_used():

0 commit comments

Comments
 (0)