Problem
Tests were connecting to the dev database (ocotilloapi_dev) instead of the test database (ocotilloapi_test).
Root Cause
In db/engine.py, load_dotenv(override=True) overwrites the POSTGRES_DB=ocotilloapi_test environment variable set by the test framework in tests/__init__.py with the value from .env (typically ocotilloapi_dev).
Impact
- Tests may pollute or read from dev database
- Test isolation is compromised
- Unexpected test failures due to database state mismatches
Fix
Change load_dotenv(override=True) to load_dotenv(override=False) so pre-set environment variables (from the test framework) are preserved.
Affected Files
db/engine.py
tests/__init__.py (sets test database)
Problem
Tests were connecting to the dev database (
ocotilloapi_dev) instead of the test database (ocotilloapi_test).Root Cause
In
db/engine.py,load_dotenv(override=True)overwrites thePOSTGRES_DB=ocotilloapi_testenvironment variable set by the test framework intests/__init__.pywith the value from.env(typicallyocotilloapi_dev).Impact
Fix
Change
load_dotenv(override=True)toload_dotenv(override=False)so pre-set environment variables (from the test framework) are preserved.Affected Files
db/engine.pytests/__init__.py(sets test database)