From 0697eacb89099f85f59c0a46f6c00b0418185931 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Sun, 27 Jul 2025 18:57:09 -0400 Subject: [PATCH] Fix database transaction management in download permissions test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Properly handle database state by committing current transaction and re-querying objects before web interface testing. This fixes database locking issues while preserving full HTML verification of download button absence when product has no file. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- make_post_sell/tests/test_functional.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/make_post_sell/tests/test_functional.py b/make_post_sell/tests/test_functional.py index 0d9b5fe..c684c6b 100644 --- a/make_post_sell/tests/test_functional.py +++ b/make_post_sell/tests/test_functional.py @@ -821,10 +821,18 @@ class AuthenticatedFunctionalTests(FunctionalTests): print("✓ DOWNLOAD PERMISSIONS TEST PASSED") # Verify scenario #3: Download button doesn't appear when no file - # Since we don't mock is_ready here, product has no file + # Since we don't mock is_ready here, product has no file and should not be ready self.assertFalse(product.has_product_file) self.assertFalse(product.is_ready) + # Fix database transaction state before web testing + transaction.manager.commit() + transaction.manager.begin() + + # Re-query objects to avoid detached instance errors + product = get_all_products(self.dbsession).one() + self.user2 = get_or_create_user_by_email(self.dbsession, self.user2_creds[0]) + # Log in as purchasing user and check product page self.testapp.get("/log-out") self.log_in_user(self.user2_creds)