Fix integration tests: ensure Flask instance directory exists

The integration tests were failing in GitHub Actions with 'unable to open
database file' errors because the Flask instance directory didn't exist.

The app.py code at line 40 creates a database URI using app.instance_path,
which requires that directory to exist. In GitHub Actions, this directory
doesn't exist by default, causing SQLite to fail when trying to create
the database file (even though tests override to use :memory:).

Solution: Create instance directory in setUp() before app context is pushed.

Changes:
- Add os.makedirs(app.app.instance_path, exist_ok=True) in setUp()
- Also fixed temp file paths to use absolute paths for research directory
- All 9 integration tests now pass locally

This ensures tests work in both local and GitHub Actions environments.
This commit is contained in:
Russell Ballestrini 2025-11-10 17:30:53 -05:00
parent 4f8cf1ce6a
commit aa1651ae81

View file

@ -32,6 +32,10 @@ class TestFlaskAppActivityFunctions(unittest.TestCase):
def setUp(self):
"""Set up test Flask application with in-memory database"""
# Ensure instance directory exists (GitHub Actions might not have it)
import os
os.makedirs(app.app.instance_path, exist_ok=True)
# Store original database URI
self.original_db_uri = app.app.config.get("SQLALCHEMY_DATABASE_URI")