"""Tests for the new-homes search pass (mustHave=newHome) channel wiring.""" import rightmove from constants import CHANNELS, NEW_HOMES_CHANNEL from rightmove import _collect_search_props def _capture_params(monkeypatch): captured: list[dict] = [] def fake_fetch(client, url, params): captured.append(dict(params)) return {"properties": [], "resultCount": "0"} monkeypatch.setattr(rightmove, "fetch_with_retry", fake_fetch) return captured def test_new_homes_channel_sends_must_have_new_home(monkeypatch): captured = _capture_params(monkeypatch) _collect_search_props(None, "749", "E14", NEW_HOMES_CHANNEL) assert captured, "no search request was issued" assert captured[0].get("mustHave") == "newHome" # New homes are still requested on the BUY channel; only the filter differs. assert captured[0]["channel"] == "BUY" assert captured[0]["transactionType"] == "BUY" def test_resale_channel_sends_no_extra_filters(monkeypatch): captured = _capture_params(monkeypatch) _collect_search_props(None, "749", "E14", CHANNELS[0]) assert captured, "no search request was issued" assert "mustHave" not in captured[0]