~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
test(journal_quality): make DOAJ accessor tests self-contained (#4857)
LearningCircuit17388c9434b9
diff --git a/tests/journal_quality/test_db_accessors.py b/tests/journal_quality/test_db_accessors.pyindex 08c0d440f9..3cd4d0850d 100644--- a/tests/journal_quality/test_db_accessors.py+++ b/tests/journal_quality/test_db_accessors.py@@ -11,6 +11,7 @@ import osimport sqlite3import time+import pytestfrom local_deep_research.journal_quality.db import (JOURNAL_QUALITY_SCHEMA_VERSION,@@ -69,42 +70,112 @@ def _openalex_id_for_ror(ref_db, ror_id):# ---------------------------------------------------------------------------+def doaj_db():+ """A ``JournalQualityDB`` backed by an in-memory DB with controlled rows.++ The DOAJ accessor tests must not use the shared ``ref_db`` (real bundled+ file): that fixture *skips* in CI where the file is absent, and worse it+ makes these tests *fail* (not skip) on a machine whose local+ ``journal_quality.db`` was built without ``doaj_journals.json`` — in that+ case ``is_in_doaj`` is 0 for every row, so the positive assertions can+ never hold. Wiring a small fixed dataset makes ``lookup_doaj`` /+ ``is_in_doaj`` deterministic and lets them actually run in CI.+ """+ from sqlalchemy import create_engine+ from sqlalchemy.orm import sessionmaker+ from sqlalchemy.pool import StaticPool++ from local_deep_research.journal_quality.models import (+ JournalQualityBase,+ Source,+ )+ from local_deep_research.utilities.citation_normalizer import (+ normalize_issn,+ )++ # StaticPool + a single shared connection keeps the in-memory DB alive for+ # the whole fixture (a plain sqlite:// would get a fresh empty DB per+ # connection).+ engine = create_engine(+ "sqlite://",+ connect_args={"check_same_thread": False},+ poolclass=StaticPool,+ )+ JournalQualityBase.metadata.create_all(engine)+ session_local = sessionmaker(bind=engine, expire_on_commit=False)+ with session_local() as s:+ s.add(+ Source(+ name="PLoS ONE",+ name_lower="plos one",+ issn=normalize_issn(DOAJ_ISSN),+ publisher="PLOS",+ is_in_doaj=True,+ score_source="doaj",+ )+ )+ # Nature: present in sources but NOT in DOAJ — the negative example+ # that exercises the is_in_doaj filter rather than a missing row.+ s.add(+ Source(+ name="Nature",+ name_lower="nature",+ issn=normalize_issn(NON_DOAJ_ISSN),+ publisher="Springer Nature",+ is_in_doaj=False,+ score_source="openalex",+ )+ )+ s.commit()++ db = JournalQualityDB()+ # Pre-wire the engine/session so _ensure_engine() short-circuits and the+ # accessor logic runs against our dataset, never the real DB path.+ db._engine = engine+ db._SessionLocal = session_local+ try:+ yield db+ finally:+ engine.dispose()++class TestLookupDoaj:"""DOAJ lookup by ISSN (query against is_in_doaj flag on Source rows)."""- def test_lookup_doaj_journal_returns_dict(self, ref_db):- result = ref_db.lookup_doaj(issn=DOAJ_ISSN)+ def test_lookup_doaj_journal_returns_dict(self, doaj_db):+ result = doaj_db.lookup_doaj(issn=DOAJ_ISSN)assert result is not None- assert "name" in result- assert "publisher" in result+ assert result["name"] == "PLoS ONE"+ assert result["publisher"] == "PLOS"- def test_lookup_non_doaj_journal_returns_none(self, ref_db):+ def test_lookup_non_doaj_journal_returns_none(self, doaj_db):# Nature exists in the sources table but is not in DOAJ, so the# DOAJ-only lookup must filter it out.- assert ref_db.lookup_doaj(issn=NON_DOAJ_ISSN) is None+ assert doaj_db.lookup_doaj(issn=NON_DOAJ_ISSN) is None- def test_lookup_nonexistent_issn_returns_none(self, ref_db):- result = ref_db.lookup_doaj(issn="0000-0000")+ def test_lookup_nonexistent_issn_returns_none(self, doaj_db):+ result = doaj_db.lookup_doaj(issn="0000-0000")assert result is None- def test_lookup_none_issn_returns_none(self, ref_db):- result = ref_db.lookup_doaj(issn=None)+ def test_lookup_none_issn_returns_none(self, doaj_db):+ result = doaj_db.lookup_doaj(issn=None)assert result is None- def test_lookup_empty_issn_returns_none(self, ref_db):- result = ref_db.lookup_doaj(issn="")+ def test_lookup_empty_issn_returns_none(self, doaj_db):+ result = doaj_db.lookup_doaj(issn="")assert result is Noneclass TestIsInDoaj:- def test_doaj_journal_is_true(self, ref_db):- assert ref_db.is_in_doaj(DOAJ_ISSN) is True+ def test_doaj_journal_is_true(self, doaj_db):+ assert doaj_db.is_in_doaj(DOAJ_ISSN) is True- def test_non_doaj_journal_is_false(self, ref_db):- assert ref_db.is_in_doaj(NON_DOAJ_ISSN) is False+ def test_non_doaj_journal_is_false(self, doaj_db):+ assert doaj_db.is_in_doaj(NON_DOAJ_ISSN) is False- def test_nonexistent_issn(self, ref_db):- assert ref_db.is_in_doaj("0000-0000") is False+ def test_nonexistent_issn(self, doaj_db):+ assert doaj_db.is_in_doaj("0000-0000") is False# ---------------------------------------------------------------------------