gendesign/tradein-mvp/backend/tests/test_extract_short_addr.py
bot-backend cdf493f345
All checks were successful
Deploy / changes (push) Successful in 9s
Deploy Trade-In / changes (push) Successful in 13s
Deploy / build-frontend (push) Has been skipped
Deploy / deploy-caddy (push) Has been skipped
Deploy Trade-In / build-frontend (push) Has been skipped
Deploy Trade-In / build-browser (push) Has been skipped
Deploy / build-backend (push) Successful in 2m23s
Deploy Trade-In / test (push) Successful in 3m56s
Deploy / build-worker (push) Successful in 4m16s
Deploy Trade-In / build-backend (push) Successful in 1m19s
Deploy / deploy (push) Successful in 1m49s
Deploy / deploy-status (push) Successful in 1s
Deploy / perimeter-smoke (push) Successful in 12s
Deploy Trade-In / deploy (push) Successful in 2m25s
Deploy Trade-In / deploy-status (push) Successful in 1s
Deploy Trade-In / perimeter-smoke (push) Successful in 11s
chore(format): нормализация под ruff 0.15.20 — 161 файл, только формат (#2864) (#3022)
2026-08-21 12:01:52 +00:00

48 lines
1.7 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Unit tests for _extract_short_addr in app.services.estimator.
Covers real Ekaterinburg address formats: full admin chain, Россия/РФ prefix,
apartment stripped, prospect keyword, korpus stripped, non-street fallback, None passthrough.
"""
from app.services.estimator import _extract_short_addr
def test_full_admin_chain() -> None:
assert (
_extract_short_addr("Свердловская область, г. Екатеринбург, Склад, ул. Заводская, д. 44-а")
== "ул. Заводская, д. 44-а"
)
def test_russia_prefix() -> None:
assert _extract_short_addr("Россия, Екатеринбург, ул. Малышева, 1") == "ул. Малышева, 1"
def test_apt_stripped() -> None:
out = _extract_short_addr("Екатеринбург, ул. Ленина, 5, кв. 12")
assert out is not None
assert "кв" not in out
assert out.startswith("ул. Ленина")
def test_prospekt_keyword() -> None:
out = _extract_short_addr("г. Екатеринбург, проспект Ленина, 50")
assert out is not None
assert out.startswith("проспект Ленина")
def test_korp_stripped() -> None:
out = _extract_short_addr("Екатеринбург, ул. Крауля, 48, корп. 2")
assert out is not None
assert "корп" not in out.lower()
def test_no_street_keyword_returns_fallback() -> None:
# Should not crash; either returns stripped str or None.
out = _extract_short_addr("Industrial zone X")
assert out is None or "Industrial" in out
def test_none_passthrough() -> None:
assert _extract_short_addr(None) is None
assert _extract_short_addr("") is None