27 lines
842 B
Python
27 lines
842 B
Python
from __future__ import annotations
|
|
|
|
import pytest
|
|
from pydantic import ValidationError
|
|
|
|
from iaai_scraper.api.routes.tasks import SyncListingRequest, SyncVehicleRequest
|
|
|
|
|
|
def test_sync_vehicle_request_rejects_empty_vehicle_url() -> None:
|
|
with pytest.raises(ValidationError):
|
|
SyncVehicleRequest(vehicle_url=" ")
|
|
|
|
|
|
def test_sync_vehicle_request_normalizes_whitespace_fields() -> None:
|
|
body = SyncVehicleRequest(vehicle_url=" https://www.iaai.com/VehicleDetails/123 ", lane=" ")
|
|
|
|
assert body.vehicle_url == "https://www.iaai.com/VehicleDetails/123"
|
|
assert body.lane == "iaai"
|
|
|
|
|
|
def test_sync_listing_request_normalizes_empty_filters_and_lane() -> None:
|
|
body = SyncListingRequest(make=" ", model="\t", lane=" ")
|
|
|
|
assert body.make is None
|
|
assert body.model is None
|
|
assert body.lane == "iaai_cars"
|