From patchwork Wed Dec 17 02:27:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 947 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765938543; bh=264U/O3iKDxXZnbPez2HnLVZhfAHzzQ+GpWRT6aG1fQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=hSA14bRLzbIWYfgTruiqune29KJZ2+eY518VQD0jnqj6gfqEQ6WrpbGK4m7M7/fVj uJVGeRTHojE7c4JraFf2lR0MYND+mfmyc80msk2LLpBg6PeXsycHW6+u58XLyfpxMt QsSEwvv/Zp3nIFdfDTHh8MtKXxUOz5mGRtASctEqpplb/9M/bw27riAX4EPtsLyVhz po/MB+/mYoJreEfZle1PFNuOTX/ig/tCAjMwWUjnciDStml7RG5OaDwHkxbydukyl4 nQEVczhcRbDLIB/DO+LEaJ7t3eQUPH9GRa7eebjxgq5H4CVr6AyWzGfPiCKAeZ3V3k qnRjkL5OCL6YQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3020B68ABD for ; Tue, 16 Dec 2025 19:29:03 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id tvJzynN6CXES for ; Tue, 16 Dec 2025 19:29:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765938543; bh=264U/O3iKDxXZnbPez2HnLVZhfAHzzQ+GpWRT6aG1fQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=hSA14bRLzbIWYfgTruiqune29KJZ2+eY518VQD0jnqj6gfqEQ6WrpbGK4m7M7/fVj uJVGeRTHojE7c4JraFf2lR0MYND+mfmyc80msk2LLpBg6PeXsycHW6+u58XLyfpxMt QsSEwvv/Zp3nIFdfDTHh8MtKXxUOz5mGRtASctEqpplb/9M/bw27riAX4EPtsLyVhz po/MB+/mYoJreEfZle1PFNuOTX/ig/tCAjMwWUjnciDStml7RG5OaDwHkxbydukyl4 nQEVczhcRbDLIB/DO+LEaJ7t3eQUPH9GRa7eebjxgq5H4CVr6AyWzGfPiCKAeZ3V3k qnRjkL5OCL6YQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2078C68AFF for ; Tue, 16 Dec 2025 19:29:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765938541; bh=m1ZtOK1hUo7cymAgbtWqr3eL5ZJbozDA+5AYMyoBmqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BgEW8pkyYr3oEWnnSMC3ix2f/2GUrq/mJ75/kmoGjQOdCqBp07M0+VAN1Pab+ryhB 1BGeO58WRG05oFCXjGZkPKWStyCpyIseCv/HExwy7ldrQL/bH15Y/22vcqwszJq6kS TDaU/sB/qxdLF/bg0GhxSAQbK6/wKTkHKW2C0ILtIBCzSXya7G8Jl34JHdXYQiErMW brUfp4LSwLT2A65pdvZpKrSqqYHAfT7a+VfENjY5BkrF+yEOPNurtuDPeXwGglnMYn Yulx9NzSXn6Rphfsgc1mqboK9sN5gzJKFCEl5cYj+GSetRZwnlxQ4hFN9SkZDaBfTS o/CWsxke4M8EQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 89AFC68ABD; Tue, 16 Dec 2025 19:29:01 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id KGWJiF_rTvjC; Tue, 16 Dec 2025 19:29:01 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765938537; bh=D6lYX8N6TgiCnPuMzMQMl9i9wrw4B86NVkFFBUteINw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MPkqCB1nOLrUn0CgmVue6eOj7BwethqFkWF2w/M0tUbkO9Kcq6fg6M6fFO+6SYUXs QdejVnlsd0nukH1BNyVK71jOFxTUk5D/Vxxkgyx/PPq3EFd5KLGxzI/bMUDstFgmHu cu6rZzAKMaJvWJQIjz40OXsYt55Bv9TEQYDe5WYb0rQqgekN/ZE2UiyyinTOrnGJ87 RBqYmtRutmaYIXPzg1+1ECPQuG5T388sh0pNwpXjIEBnpCnpfaRMBrM9BEcv50X164 uLXfTv2mDHy7ZZnw4tkBqYWir6/LAYztuyNzOEI822BPh8pStOzD1RPeuwh5qMgOkt kTOT/YWbYN3Eg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 209CA6884F; Tue, 16 Dec 2025 19:28:57 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 16 Dec 2025 19:27:53 -0700 Message-ID: <20251217022823.392557-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251217022823.392557-1-sjg@u-boot.org> References: <20251217022823.392557-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: MC6Y6JIC4XNYDH46QDDYO6MJWZ6ZLK2N X-Message-ID-Hash: MC6Y6JIC4XNYDH46QDDYO6MJWZ6ZLK2N X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/24] pickman: Complete database.py coverage List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add tests for the remaining uncovered database.py code paths: - Duplicate database creation error - Already open error when opening twice - Already closed error when closing twice - rollback() method This brings database.py to 100% test coverage. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- tools/pickman/ftest.py | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tools/pickman/ftest.py b/tools/pickman/ftest.py index b479f2e0ecd..cc4a5727ac4 100644 --- a/tools/pickman/ftest.py +++ b/tools/pickman/ftest.py @@ -314,6 +314,53 @@ class TestDatabase(unittest.TestCase): self.assertIs(dbs1, dbs2) dbs1.close() + def test_duplicate_database_error(self): + """Test creating duplicate database raises error.""" + with terminal.capture(): + dbs = database.Database(self.db_path) + dbs.start() + with self.assertRaises(ValueError) as ctx: + database.Database(self.db_path) + self.assertIn('already a database', str(ctx.exception)) + dbs.close() + + def test_open_already_open_error(self): + """Test opening already open database raises error.""" + with terminal.capture(): + dbs = database.Database(self.db_path) + dbs.start() + with self.assertRaises(ValueError) as ctx: + dbs.open_it() + self.assertIn('Already open', str(ctx.exception)) + dbs.close() + + def test_close_already_closed_error(self): + """Test closing already closed database raises error.""" + with terminal.capture(): + dbs = database.Database(self.db_path) + dbs.start() + dbs.close() + with self.assertRaises(ValueError) as ctx: + dbs.close() + self.assertIn('Already closed', str(ctx.exception)) + + def test_rollback(self): + """Test rollback discards uncommitted changes.""" + with terminal.capture(): + dbs = database.Database(self.db_path) + dbs.start() + dbs.source_set('us/next', 'abc123') + dbs.commit() + + # Make a change but don't commit + dbs.source_set('us/next', 'def456') + # Rollback should discard the change + dbs.rollback() + + result = dbs.source_get('us/next') + self.assertEqual(result, 'abc123') + dbs.close() + def test_source_get_all(self): """Test getting all sources.""" with terminal.capture():