diff --git a/test_provenance.py b/test_provenance.py index 4d51400..7f95b44 100644 --- a/test_provenance.py +++ b/test_provenance.py @@ -104,7 +104,7 @@ def test_copied_and_symlinked_standalone_report_executed_bytes(self): report = json.loads(result.stdout) self.assertEqual(hashlib.sha256(copied.read_bytes()).hexdigest(), report["tool"]["executable_sha256"]) - def test_partial_receipt_has_linked_export_and_publication_is_not_retried(self): + def test_incomplete_inventory_receipt_links_exact_export(self): when = datetime(2026, 1, 2, tzinfo=timezone.utc) with tempfile.TemporaryDirectory() as directory: source = Path(directory) / "invalid.json" @@ -115,19 +115,6 @@ def test_partial_receipt_has_linked_export_and_publication_is_not_retried(self): envelope = json.loads(receipt.read_text(encoding="utf-8")) self.assertFalse(envelope["inventory"]["complete"]) self.assertEqual(hashlib.sha256(text.encode()).hexdigest(), envelope["export_sha256"]) - receipt.unlink() - original_publish = c.publish - calls = [] - def interrupt_output(data, output, force, state): - calls.append(output) - if len(calls) == 2: - raise KeyboardInterrupt - return original_publish(data, output, force, state) - with mock.patch.object(c, "publish", side_effect=interrupt_output): - code, text, _ = self.run_cli(["--sbom", str(source), "--consumer", "sharp", "--receipt", str(receipt)], when) - self.assertEqual((130, ""), (code, text)) - self.assertEqual([receipt, None], calls) - self.assertTrue(receipt.is_file()) def test_clock_requires_an_aware_datetime(self): source = Path(__file__).parent / "examples/inventory.sbom.json" @@ -180,7 +167,11 @@ def test_consumer_staging_interrupt_cleans_owned_temporary_but_retains_receipt(s if force: output.write_bytes(b"previous consumer evidence") args.append("--force") - with mock.patch.object(c.os, "fsync", side_effect=[None, KeyboardInterrupt]) as sync: + def interrupt_consumer_staging(_fd): + if sync.call_count == 2: + raise KeyboardInterrupt + + with mock.patch.object(c.os, "fsync", side_effect=interrupt_consumer_staging) as sync: code, text, _ = self.run_cli(args, datetime(2026, 1, 2, tzinfo=timezone.utc)) self.assertEqual((130, ""), (code, text)) self.assertEqual(2, sync.call_count) # No second attempt to publish the pair.