~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(tests): add try/finally guards for engine disposal in alembic tests (#3212)
LearningCircuit2603cdb121eb
diff --git a/tests/database/test_alembic_migrations.py b/tests/database/test_alembic_migrations.pyindex e7a3957f40..6fac0bb27d 100644--- a/tests/database/test_alembic_migrations.py+++ b/tests/database/test_alembic_migrations.py@@ -4577,63 +4577,65 @@ class TestMigrationAppliesSchemaChanges:without progress columns, then run 0002 and verify column properties."""engine = create_engine(f"sqlite:///{tmp_path / 'old_schema_props.db'}")-- # Create task_metadata WITHOUT progress columns (simulating old schema)- with engine.begin() as conn:- conn.execute(- text(- """- CREATE TABLE task_metadata (- task_id VARCHAR PRIMARY KEY,- status VARCHAR NOT NULL,- task_type VARCHAR NOT NULL,- created_at DATETIME,- started_at DATETIME,- completed_at DATETIME,- error_message VARCHAR,- priority INTEGER DEFAULT 0,- retry_count INTEGER DEFAULT 0,- max_retries INTEGER DEFAULT 3+ try:+ # Create task_metadata WITHOUT progress columns (simulating old schema)+ with engine.begin() as conn:+ conn.execute(+ text(+ """+ CREATE TABLE task_metadata (+ task_id VARCHAR PRIMARY KEY,+ status VARCHAR NOT NULL,+ task_type VARCHAR NOT NULL,+ created_at DATETIME,+ started_at DATETIME,+ completed_at DATETIME,+ error_message VARCHAR,+ priority INTEGER DEFAULT 0,+ retry_count INTEGER DEFAULT 0,+ max_retries INTEGER DEFAULT 3+ )+ """)- """)- )- # Run the full migration — 0001 will create remaining tables,- # and 0002 will add the missing progress columns- run_migrations(engine)+ # Run the full migration — 0001 will create remaining tables,+ # and 0002 will add the missing progress columns+ run_migrations(engine)- # AFTER: verify columns exist with correct properties- inspector = inspect(engine)- col_map = {c["name"]: c for c in inspector.get_columns("task_metadata")}+ # AFTER: verify columns exist with correct properties+ inspector = inspect(engine)+ col_map = {+ c["name"]: c for c in inspector.get_columns("task_metadata")+ }- assert "progress_current" in col_map- assert "progress_total" in col_map- assert "progress_message" in col_map- assert "metadata_json" in col_map+ assert "progress_current" in col_map+ assert "progress_total" in col_map+ assert "progress_message" in col_map+ assert "metadata_json" in col_map- # Verify nullable constraints- assert col_map["progress_message"]["nullable"] is True- assert col_map["metadata_json"]["nullable"] is True+ # Verify nullable constraints+ assert col_map["progress_message"]["nullable"] is True+ assert col_map["metadata_json"]["nullable"] is True- # Verify defaults work via INSERT without specifying progress columns- with engine.begin() as conn:- conn.execute(- text(- "INSERT INTO task_metadata (task_id, status, task_type) "- "VALUES ('default-test', 'queued', 'research')"- )- )- row = conn.execute(- text(- "SELECT progress_current, progress_total FROM task_metadata "- "WHERE task_id='default-test'"+ # Verify defaults work via INSERT without specifying progress columns+ with engine.begin() as conn:+ conn.execute(+ text(+ "INSERT INTO task_metadata (task_id, status, task_type) "+ "VALUES ('default-test', 'queued', 'research')"+ ))- ).fetchone()- assert row[0] == 0 # default- assert row[1] == 0 # default-- engine.dispose()+ row = conn.execute(+ text(+ "SELECT progress_current, progress_total FROM task_metadata "+ "WHERE task_id='default-test'"+ )+ ).fetchone()+ assert row[0] == 0 # default+ assert row[1] == 0 # default+ finally:+ engine.dispose()def test_orm_crud_after_initialize_database(self, tmp_path):"""ORM CRUD works after initialize_database() — the production entry point."""@@ -4641,81 +4643,82 @@ class TestMigrationAppliesSchemaChanges:from local_deep_research.database.models.settings import SettingTypeengine = create_engine(f"sqlite:///{tmp_path / 'crud.db'}")- Session = sessionmaker(bind=engine)-- # Production entry point- with Session() as session:- initialize_database(engine, session)+ try:+ Session = sessionmaker(bind=engine)- # Verify migrations ran- assert get_current_revision(engine) == get_head_revision()+ # Production entry point+ with Session() as session:+ initialize_database(engine, session)- with Session() as session:- # CREATE — TaskMetadata with 0002 progress columns- task = TaskMetadata(- task_id="orm-test-001",- status="queued",- task_type="research",- progress_current=5,- progress_total=100,- progress_message="Searching...",- metadata_json={"source": "test"},- )- session.add(task)- session.commit()+ # Verify migrations ran+ assert get_current_revision(engine) == get_head_revision()- # READ — verify all fields round-trip- loaded = (- session.query(TaskMetadata)- .filter_by(task_id="orm-test-001")- .first()- )- assert loaded is not None- assert loaded.progress_current == 5- assert loaded.progress_total == 100- assert loaded.progress_message == "Searching..."- assert loaded.metadata_json == {"source": "test"}-- # UPDATE- loaded.progress_current = 50- loaded.progress_message = "Halfway"- session.commit()- reloaded = (- session.query(TaskMetadata)- .filter_by(task_id="orm-test-001")- .first()- )- assert reloaded.progress_current == 50- assert reloaded.progress_message == "Halfway"-- # CREATE — Setting model (value is JSON type, key must be unique)- setting = Setting(- key="test.migration.orm",- value="works",- type=SettingType.APP,- name="Test Setting",- category="test",- )- session.add(setting)- session.commit()- loaded_setting = (- session.query(Setting)- .filter_by(key="test.migration.orm")- .first()- )- assert loaded_setting.value == "works"+ with Session() as session:+ # CREATE — TaskMetadata with 0002 progress columns+ task = TaskMetadata(+ task_id="orm-test-001",+ status="queued",+ task_type="research",+ progress_current=5,+ progress_total=100,+ progress_message="Searching...",+ metadata_json={"source": "test"},+ )+ session.add(task)+ session.commit()- # DELETE- session.delete(reloaded)- session.commit()- assert (- session.query(TaskMetadata)- .filter_by(task_id="orm-test-001")- .first()- is None- )+ # READ — verify all fields round-trip+ loaded = (+ session.query(TaskMetadata)+ .filter_by(task_id="orm-test-001")+ .first()+ )+ assert loaded is not None+ assert loaded.progress_current == 5+ assert loaded.progress_total == 100+ assert loaded.progress_message == "Searching..."+ assert loaded.metadata_json == {"source": "test"}++ # UPDATE+ loaded.progress_current = 50+ loaded.progress_message = "Halfway"+ session.commit()+ reloaded = (+ session.query(TaskMetadata)+ .filter_by(task_id="orm-test-001")+ .first()+ )+ assert reloaded.progress_current == 50+ assert reloaded.progress_message == "Halfway"++ # CREATE — Setting model (value is JSON type, key must be unique)+ setting = Setting(+ key="test.migration.orm",+ value="works",+ type=SettingType.APP,+ name="Test Setting",+ category="test",+ )+ session.add(setting)+ session.commit()+ loaded_setting = (+ session.query(Setting)+ .filter_by(key="test.migration.orm")+ .first()+ )+ assert loaded_setting.value == "works"- engine.dispose()+ # DELETE+ session.delete(reloaded)+ session.commit()+ assert (+ session.query(TaskMetadata)+ .filter_by(task_id="orm-test-001")+ .first()+ is None+ )+ finally:+ engine.dispose()def test_downgrade_upgrade_roundtrip_verifies_column_properties(self, migrated_to_head