from property_bot.listings import format_listing, listing_from_event def event() -> dict[str, object]: return { "type": "listing.new", "listing": { "externalId": "abc", "url": "https://example.test/listing", "title": "Просторная квартира", "price": 4500, "currency": "PLN", "additionalFees": 700, "area": 62.5, "rooms": 3, "location": {"city": "Warszawa", "district": "Wola", "street": "Prosta"}, "images": ["https://example.test/image.jpg"], }, } def test_parses_and_formats_listing() -> None: listing = listing_from_event(event()) assert listing is not None assert listing.images == ("https://example.test/image.jpg",) text = format_listing(listing) assert "4500 PLN" in text assert "Warszawa, Wola, Prosta" in text assert "https://example.test/listing" in text def test_ignores_ready_and_incomplete_events() -> None: assert listing_from_event({"type": "service.ready"}) is None assert listing_from_event({"type": "listing.new", "listing": {}}) is None