Fix buy listing support: thread ListingType through processing pipeline
The listing processor was hardcoded to create RentListing objects and query only the rentlisting table. Buy listings fetched from Rightmove were stored in the wrong table with missing fields. This threads ListingType through ListingProcessor and all Step subclasses so the correct model (RentListing/BuyListing) is created, the correct table is queried, and buy-specific fields (service_charge, lease_left) are parsed from the API response and included in GeoJSON streaming output.
This commit is contained in:
parent
5e48a26958
commit
e5ce8c1201
6 changed files with 116 additions and 41 deletions
|
|
@ -2,7 +2,7 @@
|
|||
from datetime import datetime
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
import pytest
|
||||
from models.listing import FurnishType
|
||||
from models.listing import FurnishType, ListingType
|
||||
from listing_processor import (
|
||||
_parse_furnish_type,
|
||||
_parse_available_from,
|
||||
|
|
@ -69,7 +69,7 @@ class TestListingProcessor:
|
|||
for step in processor.process_steps:
|
||||
step.needs_processing = AsyncMock(return_value=False)
|
||||
await processor.process_listing(123)
|
||||
mock_repo.mark_seen.assert_awaited_once_with(123)
|
||||
mock_repo.mark_seen.assert_awaited_once_with(123, ListingType.RENT)
|
||||
|
||||
async def test_process_listing_returns_none_on_step_failure(self):
|
||||
"""Test that a step failure returns None."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue