first implementation
This commit is contained in:
@@ -380,7 +380,7 @@ def _make_raw(job_id: str, company: str = "Acme") -> RawJob:
|
||||
class TestRunBatch:
|
||||
"""Monkeypatched run_batch tests — no network, no real providers."""
|
||||
|
||||
def _patch_all(self, monkeypatch, raw_jobs: list[RawJob]) -> None:
|
||||
def _patch_all(self, monkeypatch, raw_jobs: list[RawJob]) -> MagicMock:
|
||||
"""Patch all external I/O in pipeline so tests run offline."""
|
||||
from jobsource.careers.cascade import CareersResult
|
||||
|
||||
@@ -418,6 +418,7 @@ class TestRunBatch:
|
||||
cm.__enter__ = lambda s: MagicMock()
|
||||
cm.__exit__ = MagicMock(return_value=False)
|
||||
monkeypatch.setattr("jobsource.pipeline.build_client", lambda: cm)
|
||||
return fake_source
|
||||
|
||||
def test_new_jobs_processed(self, tmp_path: Path, monkeypatch) -> None:
|
||||
from jobsource.pipeline import run_batch
|
||||
@@ -469,6 +470,20 @@ class TestRunBatch:
|
||||
assert summary.new == 3
|
||||
assert summary.position_found == 3
|
||||
|
||||
def test_fetch_limit_matches_batch_size(self, tmp_path: Path, monkeypatch) -> None:
|
||||
"""Immediate re-runs only re-fetch the requested batch window."""
|
||||
from jobsource.pipeline import run_batch
|
||||
|
||||
raw = [_make_raw(str(i), company=f"Co{i}") for i in range(10)]
|
||||
source = self._patch_all(monkeypatch, raw)
|
||||
|
||||
db = Database(path=tmp_path / "fetch-limit.db")
|
||||
summary = run_batch(batch_size=3, search_terms=["eng"], db=db)
|
||||
|
||||
assert summary.new == 3
|
||||
source.fetch_recent_jobs.assert_called_once()
|
||||
assert source.fetch_recent_jobs.call_args.kwargs["results_wanted"] == 3
|
||||
|
||||
def test_resolve_failure_marks_needs_review(self, tmp_path: Path, monkeypatch) -> None:
|
||||
"""Jobs where resolve_website returns None get needs_review, not failed."""
|
||||
from jobsource.pipeline import run_batch
|
||||
|
||||
Reference in New Issue
Block a user