c9383788de
Co-authored-by: Copilot <copilot@github.com>
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
from finn_eiendom.eiendom_no import (
|
|
build_unit_vector,
|
|
decode_unit_vector,
|
|
parse_eiendom_unit_json,
|
|
parse_similar_units_json,
|
|
)
|
|
from tests.fixtures import (
|
|
SAMPLE_EIENDOM_SIMILAR_UNITS_JSON,
|
|
SAMPLE_EIENDOM_UNIT_JSON,
|
|
)
|
|
|
|
|
|
def test_parse_eiendom_unit_json():
|
|
unit = parse_eiendom_unit_json(SAMPLE_EIENDOM_UNIT_JSON["units"][0])
|
|
assert unit.unit_code == "c-gxw-xmyum-s2a"
|
|
assert unit.address == "Fernerveien 42, 0554 Oslo"
|
|
assert unit.estimated_selling_price == 7650000
|
|
assert unit.listing_sqm_price == 93500
|
|
|
|
|
|
def test_unit_vector_roundtrip():
|
|
unit = parse_eiendom_unit_json(SAMPLE_EIENDOM_UNIT_JSON["units"][0])
|
|
vector = build_unit_vector(unit)
|
|
decoded = decode_unit_vector(vector)
|
|
assert decoded["ptype"] == "APARTMENT"
|
|
assert decoded["area"] == 77
|
|
assert decoded["price"] == 7200000
|
|
assert isinstance(decoded, dict)
|
|
assert decoded["lon"] == unit.lng
|
|
|
|
|
|
def test_parse_similar_units_json():
|
|
comps = parse_similar_units_json(SAMPLE_EIENDOM_SIMILAR_UNITS_JSON)
|
|
assert len(comps) == 2
|
|
assert comps[0].unit_code == "c-recent-1"
|
|
assert comps[1].selling_price == 7350000
|