fix(asset): allow registering a monitor of an already-registered model

Registration was blocked whenever same-model candidates existed, so a
second monitor of the same model (e.g. dual monitors) could not be added.
Now only an existing asset with the same serial blocks a new one; the
UI tells serial and model candidates apart and hides 'register' only
for serial matches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-07 15:14:22 +09:00
parent 133df472d1
commit e9be17faab
5 changed files with 29 additions and 4 deletions
+15
View File
@@ -104,6 +104,21 @@ class FeatureStoreTests(unittest.TestCase):
match=self.store._monitor_matches(self.conn,"other-computer",unknown)[0]
self.assertIsNone(match["asset"]);self.assertEqual(len(match["candidates"]),2)
def test_same_model_different_serial_can_be_registered(self):
# 같은 모델(듀얼 모니터 등)이 이미 있어도 시리얼이 다르면 새 자산으로 등록된다(2026-10-07)
other = self.store.create(AssetInput(name="Display", category="monitor", model="Display 24", serial="SN-OTHER"), "actor")
match = self.store._monitor_matches(self.conn, self.computer, self.parsed)[0]
self.assertIsNone(match["asset"]); self.assertEqual(match["candidate_by"], "model")
self.assertEqual([c["id"] for c in match["candidates"]], [other])
target = self.store.register_monitor(self.computer, 0, self.monitor_payload(asset=AssetInput(name="Second", category="monitor", model="Display 24")), "actor")
self.assertNotEqual(target, other); self.assertEqual(self.conn.assets[target]["serial"], "SN-1")
def test_same_serial_still_blocks_new_registration(self):
self.store.create(AssetInput(name="Other", category="monitor", serial="SN-1", model="Different Model", manufacturer="Another"), "actor")
self.assertEqual(self.store._monitor_matches(self.conn, self.computer, self.parsed)[0]["candidate_by"], "serial")
with self.assertRaises(AssetConflict):
self.store.register_monitor(self.computer, 0, self.monitor_payload(asset=AssetInput(name="Dup", category="monitor")), "actor")
def test_existing_unique_serial_matches_automatically(self):
target=self.store.create(AssetInput(name="Existing",category="monitor",serial="sn-1"),"actor")
match=self.store._monitor_matches(self.conn,self.computer,self.parsed)[0]