This commit is contained in:
Ole
2026-05-16 06:54:17 +00:00
commit 1399f61c1a
44 changed files with 6746 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
from finn_eiendom.parser import (
clean_text,
extract_finnkode_from_url,
normalize_area,
normalize_finnkode,
normalize_number,
normalize_price,
)
def test_normalize_price():
assert normalize_price("7 200 991 kr") == 7200991
assert normalize_price("1 234") == 1234
assert normalize_price(None) is None
def test_normalize_area():
assert normalize_area("77 m²") == 77
assert normalize_area("100,5 m²") == 100
assert normalize_area("") is None
def test_normalize_number():
assert normalize_number("3 500 kr/mnd") == 3500
assert normalize_number("7,2") == 7
assert normalize_number("1.234") == 1234
assert normalize_number(None) is None
def test_normalize_finnkode():
assert normalize_finnkode(" 462400360 ") == "462400360"
assert normalize_finnkode(None) is None
def test_extract_finnkode_from_url():
assert (
extract_finnkode_from_url("https://www.finn.no/realestate/homes/ad.html?finnkode=462400360")
== "462400360"
)
assert extract_finnkode_from_url("https://www.finn.no/realestate/homes/ad.html") is None
def test_clean_text():
assert clean_text(" Hello world \n") == "Hello world"
assert clean_text(None) is None