.
This commit is contained in:
parent
909e241907
commit
1ee796b282
29 changed files with 250 additions and 126 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from transform import (
|
||||
build_listing_url,
|
||||
build_register_address,
|
||||
clean_listing_address,
|
||||
extract_full_postcode,
|
||||
|
|
@ -173,3 +174,33 @@ def test_rightmove_transform_without_detail_keeps_coordinate_logic() -> None:
|
|||
assert result is not None
|
||||
assert result["Postcode"] == "SW9 7AA"
|
||||
assert result["Postcode source"] == "coordinates"
|
||||
|
||||
|
||||
def test_build_listing_url_stamps_channel_from_new_build_flag() -> None:
|
||||
# Resale gets RES_BUY; new builds get RES_NEW.
|
||||
assert build_listing_url("/properties/200", False) == (
|
||||
"https://www.rightmove.co.uk/properties/200#/?channel=RES_BUY"
|
||||
)
|
||||
assert build_listing_url("/properties/200", True) == (
|
||||
"https://www.rightmove.co.uk/properties/200#/?channel=RES_NEW"
|
||||
)
|
||||
# An existing channel/fragment on the source URL is stripped and re-stamped.
|
||||
assert build_listing_url("/properties/200#/?channel=RES_BUY", True) == (
|
||||
"https://www.rightmove.co.uk/properties/200#/?channel=RES_NEW"
|
||||
)
|
||||
# Missing URL stays empty.
|
||||
assert build_listing_url("", True) == ""
|
||||
|
||||
|
||||
def test_rightmove_transform_tags_new_builds_res_new() -> None:
|
||||
# The Rightmove search response marks new-build developments with
|
||||
# development=True; transform_property must stamp the listing URL RES_NEW.
|
||||
new_build = {**_rightmove_prop(), "development": True}
|
||||
result = transform_property(new_build, "SW9", StubPostcodeIndex("SW9 7AA"))
|
||||
assert result is not None
|
||||
assert result["Listing URL"].endswith("#/?channel=RES_NEW")
|
||||
|
||||
# Ordinary resale (development absent/false) stays RES_BUY.
|
||||
resale = transform_property(_rightmove_prop(), "SW9", StubPostcodeIndex("SW9 7AA"))
|
||||
assert resale is not None
|
||||
assert resale["Listing URL"].endswith("#/?channel=RES_BUY")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue