chore: clarify rollback test and intentional exception handling (#193)

This commit is contained in:
Vito Sansevero
2026-10-17 07:53:51 -07:00
parent 822e6a0607
commit d3907fdc62
3 changed files with 7 additions and 3 deletions
+1
View File
@@ -1506,6 +1506,7 @@ class AdminRoutesMixin:
try:
canonical[key] = json.loads(canonical[key])
except (ValueError, TypeError):
# Preserve malformed metadata for conservative resolver rejection.
pass
if not canonical.get("prompt") and not canonical.get("parameters"):
return None
+5 -3
View File
@@ -253,13 +253,15 @@ class TestPromptPairs(unittest.TestCase):
def test_connection_helpers_leave_commit_and_rollback_to_the_caller(self):
conn = self.db.model.get_connection()
with self.assertRaisesRegex(RuntimeError, "rollback"):
def rollback_transaction():
with conn:
conn.execute("BEGIN IMMEDIATE")
self.db._save_pair(conn, "transient", "temporary", tags=["tag"])
with self.assertRaisesRegex(RuntimeError, "own transaction"):
self.save()
self.assertRaisesRegex(RuntimeError, "own transaction", self.save)
raise RuntimeError("rollback")
self.assertRaisesRegex(RuntimeError, "rollback", rollback_transaction)
self.assertEqual(self.db.list_prompt_pairs()["total"], 0)
self.assertEqual(self.db.search_prompts(), [])
+1
View File
@@ -40,6 +40,7 @@ if __name__ == "__main__":
try:
server.serve_forever()
except KeyboardInterrupt:
# Ctrl+C exits normally; the finally block closes the listening socket.
pass
finally:
server.server_close()