From aa1651ae810ee72a26ebdbe6762bf2a85a6edff2 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Mon, 10 Nov 2025 17:30:53 -0500 Subject: [PATCH] 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. --- tests/integration/test_app_activity_functions.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/integration/test_app_activity_functions.py b/tests/integration/test_app_activity_functions.py index b038cd5..7f697c0 100644 --- a/tests/integration/test_app_activity_functions.py +++ b/tests/integration/test_app_activity_functions.py @@ -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")