Align car mapping contract
This commit is contained in:
@@ -246,18 +246,18 @@ class MobileDeMapper:
|
||||
listing.subtitle,
|
||||
listing.title,
|
||||
),
|
||||
selling_type="CLASSIFIED",
|
||||
selling_type="STOCK",
|
||||
one_owner=self._is_one_owner(attr.get("pvo") or raw.get("numPreviousOwners")),
|
||||
new_car=bool(raw.get("isNew") or raw.get("isConditionNew")),
|
||||
is_hidden=False,
|
||||
origin="MOBILE_DE",
|
||||
origin="MOBILEDE",
|
||||
origin_url=listing.url,
|
||||
origin_id=origin_id,
|
||||
is_damaged=is_damaged,
|
||||
evaluation=self._rating_text(raw.get("priceRating") or raw.get("rating")),
|
||||
non_smoking=True,
|
||||
non_smoking=False,
|
||||
rental=False,
|
||||
repair_history=is_damaged,
|
||||
repair_history=False,
|
||||
slug=self._slugify(" ".join(part for part in [title or f"{brand} {model}", str(year) if year is not None else ""] if part)),
|
||||
last_seen_at=datetime.now(timezone.utc),
|
||||
images=self._images_from_listing(raw),
|
||||
@@ -344,18 +344,18 @@ class MobileDeMapper:
|
||||
subtitle,
|
||||
short_title,
|
||||
),
|
||||
selling_type="CLASSIFIED",
|
||||
selling_type="STOCK",
|
||||
one_owner=one_owner,
|
||||
new_car=bool(detail.get("isNew") or detail.get("isConditionNew")),
|
||||
is_hidden=False,
|
||||
origin="MOBILE_DE",
|
||||
origin="MOBILEDE",
|
||||
origin_url=MobileDeClient.build_detail_url(listing_id),
|
||||
origin_id=origin_id,
|
||||
is_damaged=is_damaged,
|
||||
evaluation=self._rating_text(detail.get("priceRating") or detail.get("rating")),
|
||||
non_smoking=True,
|
||||
non_smoking=False,
|
||||
rental=False,
|
||||
repair_history=is_damaged,
|
||||
repair_history=False,
|
||||
slug=self._slugify(" ".join(part for part in [title or f"{brand} {model}", str(year) if year is not None else ""] if part)),
|
||||
last_seen_at=datetime.now(timezone.utc),
|
||||
images=self._images_from_listing(detail),
|
||||
|
||||
@@ -104,7 +104,8 @@ class TestMobileDeMapper(unittest.TestCase):
|
||||
)
|
||||
|
||||
self.assertEqual(record.origin_id, "mobile.de:456")
|
||||
self.assertEqual(record.origin, "MOBILE_DE")
|
||||
self.assertEqual(record.origin, "MOBILEDE")
|
||||
self.assertEqual(record.selling_type, "STOCK")
|
||||
|
||||
def test_slug_includes_year_without_duplicate_or_trailing_hyphens(self) -> None:
|
||||
record = self.mapper.listing_to_car_record(
|
||||
@@ -250,7 +251,8 @@ class TestMobileDeMapper(unittest.TestCase):
|
||||
self.assertTrue(record.one_owner)
|
||||
self.assertTrue(record.new_car)
|
||||
self.assertTrue(record.is_damaged)
|
||||
self.assertTrue(record.repair_history)
|
||||
self.assertFalse(record.repair_history)
|
||||
self.assertFalse(record.non_smoking)
|
||||
self.assertEqual(record.evaluation, "GOOD_PRICE")
|
||||
|
||||
def test_drive_mapping_uses_specific_markers_only(self) -> None:
|
||||
@@ -409,6 +411,10 @@ class TestMobileDeMapper(unittest.TestCase):
|
||||
self.assertEqual(record.engine_volume, 2993)
|
||||
self.assertEqual(record.body_type, "SUV")
|
||||
self.assertEqual(record.year, 2019)
|
||||
self.assertEqual(record.origin, "MOBILEDE")
|
||||
self.assertEqual(record.selling_type, "STOCK")
|
||||
self.assertFalse(record.non_smoking)
|
||||
self.assertFalse(record.repair_history)
|
||||
|
||||
def test_drive_prefers_explicit_attr_marker_over_title_noise(self) -> None:
|
||||
record = self.mapper.listing_to_car_record(
|
||||
|
||||
Reference in New Issue
Block a user