Initial release prep
This commit is contained in:
parent
c9b9d892f4
commit
92395b2b4b
100 changed files with 405 additions and 401 deletions
|
|
@ -11,9 +11,9 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
|||
|
||||
from app.api.runtime_deps import get_scholar_source
|
||||
from app.main import app
|
||||
from app.services.domains.publications.types import PublicationListItem
|
||||
from app.services.domains.scholar.source import FetchResult
|
||||
from app.services.domains.settings import application as user_settings_service
|
||||
from app.services.publications.types import PublicationListItem
|
||||
from app.services.scholar.source import FetchResult
|
||||
from app.services.settings import application as user_settings_service
|
||||
from app.settings import settings
|
||||
from tests.integration.helpers import insert_user, login_user
|
||||
|
||||
|
|
@ -473,7 +473,7 @@ async def test_api_admin_dbops_pdf_queue_requeue_endpoint(
|
|||
fingerprint=f"{(target_user_id + 73):064x}",
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"app.services.domains.publications.pdf_queue._schedule_rows",
|
||||
"app.services.publications.pdf_queue._schedule_rows",
|
||||
lambda **_kwargs: None,
|
||||
)
|
||||
client = TestClient(app)
|
||||
|
|
@ -517,7 +517,7 @@ async def test_api_admin_dbops_pdf_queue_requeue_all_endpoint(
|
|||
fingerprint=f"{(target_user_id + 83):064x}",
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"app.services.domains.publications.pdf_queue._schedule_rows",
|
||||
"app.services.publications.pdf_queue._schedule_rows",
|
||||
lambda **_kwargs: None,
|
||||
)
|
||||
client = TestClient(app)
|
||||
|
|
@ -1290,12 +1290,16 @@ async def test_api_settings_get_and_update(db_session: AsyncSession) -> None:
|
|||
_assert_safety_state_contract(settings_payload["safety_state"])
|
||||
assert settings_payload["safety_state"]["cooldown_active"] is False
|
||||
|
||||
policy = settings_payload["policy"]
|
||||
run_interval_minutes = max(45, int(policy["min_run_interval_minutes"]))
|
||||
request_delay_seconds = max(6, int(policy["min_request_delay_seconds"]))
|
||||
|
||||
update_response = client.put(
|
||||
"/api/v1/settings",
|
||||
json={
|
||||
"auto_run_enabled": True,
|
||||
"run_interval_minutes": 45,
|
||||
"request_delay_seconds": 6,
|
||||
"run_interval_minutes": run_interval_minutes,
|
||||
"request_delay_seconds": request_delay_seconds,
|
||||
"nav_visible_pages": ["dashboard", "scholars", "publications", "settings", "runs"],
|
||||
},
|
||||
headers=headers,
|
||||
|
|
@ -1303,8 +1307,8 @@ async def test_api_settings_get_and_update(db_session: AsyncSession) -> None:
|
|||
assert update_response.status_code == 200
|
||||
updated = update_response.json()["data"]
|
||||
assert updated["auto_run_enabled"] is True
|
||||
assert updated["run_interval_minutes"] == 45
|
||||
assert updated["request_delay_seconds"] == 6
|
||||
assert updated["run_interval_minutes"] == run_interval_minutes
|
||||
assert updated["request_delay_seconds"] == request_delay_seconds
|
||||
assert updated["nav_visible_pages"] == [
|
||||
"dashboard",
|
||||
"scholars",
|
||||
|
|
@ -2404,7 +2408,7 @@ async def test_api_publications_list_schedules_background_enrichment(
|
|||
return 1
|
||||
|
||||
monkeypatch.setattr(
|
||||
"app.services.domains.publications.application.schedule_missing_pdf_enrichment_for_user",
|
||||
"app.services.publications.application.schedule_missing_pdf_enrichment_for_user",
|
||||
_fake_schedule,
|
||||
)
|
||||
|
||||
|
|
@ -2484,7 +2488,7 @@ async def test_api_publication_retry_pdf_queues_resolution_job(
|
|||
return True
|
||||
|
||||
monkeypatch.setattr(
|
||||
"app.services.domains.publications.application.schedule_retry_pdf_enrichment_for_row",
|
||||
"app.services.publications.application.schedule_retry_pdf_enrichment_for_row",
|
||||
_fake_retry_scheduler,
|
||||
)
|
||||
|
||||
|
|
@ -2514,7 +2518,7 @@ async def test_api_publication_retry_pdf_queues_resolution_job(
|
|||
]
|
||||
|
||||
monkeypatch.setattr(
|
||||
"app.services.domains.publications.application.hydrate_pdf_enrichment_state",
|
||||
"app.services.publications.application.hydrate_pdf_enrichment_state",
|
||||
_fake_hydrate,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import pytest
|
|||
from sqlalchemy import text
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.services.domains.dbops import run_publication_link_repair
|
||||
from app.services.dbops import run_publication_link_repair
|
||||
from tests.integration.helpers import insert_user
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import pytest
|
|||
from sqlalchemy import text
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.services.domains.dbops.integrity import collect_integrity_report
|
||||
from app.services.dbops.integrity import collect_integrity_report
|
||||
|
||||
|
||||
def _check_counts(report: dict) -> dict[str, int]:
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ from sqlalchemy import select
|
|||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.db.models import CrawlRun, Publication, RunStatus, RunTriggerType, ScholarProfile, ScholarPublication
|
||||
from app.services.domains.ingestion.application import ScholarIngestionService
|
||||
from app.services.domains.openalex.types import OpenAlexWork
|
||||
from app.services.ingestion.application import ScholarIngestionService
|
||||
from app.services.openalex.types import OpenAlexWork
|
||||
from tests.integration.helpers import insert_user
|
||||
|
||||
|
||||
|
|
@ -84,9 +84,9 @@ async def test_deferred_enrichment_sweeps_previous_runs(db_session: AsyncSession
|
|||
|
||||
# We patch the client at its source, and also mock arXiv to avoid real HTTP calls
|
||||
with (
|
||||
patch("app.services.domains.openalex.client.OpenAlexClient") as MockClient,
|
||||
patch("app.services.openalex.client.OpenAlexClient") as MockClient,
|
||||
patch(
|
||||
"app.services.domains.arxiv.application.discover_arxiv_id_for_publication", new=AsyncMock(return_value=None)
|
||||
"app.services.arxiv.application.discover_arxiv_id_for_publication", new=AsyncMock(return_value=None)
|
||||
),
|
||||
):
|
||||
mock_instance = MockClient.return_value
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ from sqlalchemy import text
|
|||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.db.models import RunStatus, RunTriggerType
|
||||
from app.services.domains.ingestion.application import ScholarIngestionService
|
||||
from app.services.domains.scholar.source import FetchResult
|
||||
from app.services.ingestion.application import ScholarIngestionService
|
||||
from app.services.scholar.source import FetchResult
|
||||
from tests.integration.helpers import insert_user
|
||||
|
||||
REGRESSION_FIXTURE_DIR = Path("tests/fixtures/scholar/regression")
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker
|
|||
from app.api.runtime_deps import get_ingestion_service
|
||||
from app.db.models import CrawlRun, Publication, RunStatus, RunTriggerType
|
||||
from app.main import app
|
||||
from app.services.domains.ingestion.application import ScholarIngestionService
|
||||
from app.services.ingestion.application import ScholarIngestionService
|
||||
from tests.integration.helpers import insert_user, login_user
|
||||
|
||||
|
||||
|
|
@ -214,7 +214,7 @@ async def test_background_enrichment_preserves_canceled_status(
|
|||
return []
|
||||
|
||||
monkeypatch.setattr(
|
||||
"app.services.domains.openalex.client.OpenAlexClient",
|
||||
"app.services.openalex.client.OpenAlexClient",
|
||||
_OpenAlexClientStub,
|
||||
)
|
||||
|
||||
|
|
@ -339,7 +339,7 @@ async def test_partial_discovery_exception_keeps_new_pub_count_consistent(
|
|||
monkeypatch.setattr(service, "_resolve_publication", _resolve_publication_stub)
|
||||
|
||||
from app.db.models import ScholarProfile
|
||||
from app.services.domains.scholar.parser_types import PublicationCandidate
|
||||
from app.services.scholar.parser_types import PublicationCandidate
|
||||
|
||||
scholar = await db_session.get(ScholarProfile, scholar_profile_id)
|
||||
assert scholar is not None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue