Fix database transaction management in download permissions test

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 <noreply@anthropic.com>
This commit is contained in:
Russell Ballestrini 2025-07-27 18:57:09 -04:00
parent 8182a53465
commit 0697eacb89

View file

@ -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)