mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Fix pyright strict violations in mapper and test imports 🟪
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5797ddbda6
commit
bffac89abb
2 changed files with 15 additions and 11 deletions
|
|
@ -17,13 +17,13 @@ def map_plan(mp: MagicPlanPlan) -> Plan:
|
|||
return Plan(
|
||||
uid=mp.plan.id,
|
||||
name=mp.plan.name,
|
||||
address=_map_address(mp.plan.address),
|
||||
address=map_address(mp.plan.address),
|
||||
postcode=mp.plan.address.postal_code if mp.plan.address else None,
|
||||
floors=[_map_floor(f) for f in mp.plan_detail.plan.floors],
|
||||
)
|
||||
|
||||
|
||||
def _map_address(addr: Optional[api.Address]) -> Optional[str]:
|
||||
def map_address(addr: Optional[api.Address]) -> Optional[str]:
|
||||
if addr is None:
|
||||
return None
|
||||
street = " ".join(p for p in [addr.street_number, addr.street] if p) or None
|
||||
|
|
|
|||
|
|
@ -6,7 +6,11 @@ import pytest
|
|||
|
||||
import datatypes.magicplan.api.response as api
|
||||
from datatypes.magicplan.api.response import MagicPlanPlan, Symbol, Vec3, WallItem
|
||||
from datatypes.magicplan.domain.mapper import _map_address, _map_window, map_plan
|
||||
from datatypes.magicplan.domain.mapper import (
|
||||
_map_window, # pyright: ignore[reportPrivateUsage]
|
||||
map_address,
|
||||
map_plan,
|
||||
)
|
||||
from datatypes.magicplan.domain.models import Plan
|
||||
|
||||
FIXTURE_DIR = Path(__file__).parents[4] / "tests" / "magic_plan"
|
||||
|
|
@ -71,8 +75,8 @@ def test_room_area_rounded_to_2dp(plan: Plan) -> None:
|
|||
|
||||
def test_room_dimensions_parsed_from_string(plan: Plan) -> None:
|
||||
room = plan.floors[0].rooms[0]
|
||||
assert room.width_m == pytest.approx(3.19)
|
||||
assert room.length_m == pytest.approx(2.94)
|
||||
assert room.width_m == 3.19
|
||||
assert room.length_m == 2.94
|
||||
|
||||
|
||||
# --- Windows ---
|
||||
|
|
@ -97,7 +101,7 @@ def test_window_opening_type_prefix_stripped(plan: Plan) -> None:
|
|||
|
||||
def test_window_area_is_width_times_height(plan: Plan) -> None:
|
||||
window = plan.floors[0].rooms[0].windows[0]
|
||||
assert window.area_m2 == pytest.approx(window.width_m * window.height_m, rel=1e-2)
|
||||
assert window.area_m2 == round(window.width_m * window.height_m, 2)
|
||||
|
||||
|
||||
def test_window_dimensions_rounded_to_2dp(plan: Plan) -> None:
|
||||
|
|
@ -188,26 +192,26 @@ def test_glass_door_ventilation_opening_type(plan: Plan) -> None:
|
|||
def test_map_address_with_street_and_number() -> None:
|
||||
addr = api.Address(street_number="2", street="Laburnum Way", city="Bromley", country="GB")
|
||||
|
||||
assert _map_address(addr) == "2 Laburnum Way, Bromley, GB"
|
||||
assert map_address(addr) == "2 Laburnum Way, Bromley, GB"
|
||||
|
||||
|
||||
def test_map_address_with_street_number_only() -> None:
|
||||
addr = api.Address(street_number="2", city="Bromley", country="GB")
|
||||
|
||||
assert _map_address(addr) == "2, Bromley, GB"
|
||||
assert map_address(addr) == "2, Bromley, GB"
|
||||
|
||||
|
||||
def test_map_address_with_street_only() -> None:
|
||||
addr = api.Address(street="Laburnum Way", city="Bromley", country="GB")
|
||||
|
||||
assert _map_address(addr) == "Laburnum Way, Bromley, GB"
|
||||
assert map_address(addr) == "Laburnum Way, Bromley, GB"
|
||||
|
||||
|
||||
def test_map_address_city_absent_is_omitted() -> None:
|
||||
addr = api.Address(street_number="2", street="Laburnum Way", country="GB")
|
||||
|
||||
assert _map_address(addr) == "2 Laburnum Way, GB"
|
||||
assert map_address(addr) == "2 Laburnum Way, GB"
|
||||
|
||||
|
||||
def test_map_address_none_returns_none() -> None:
|
||||
assert _map_address(None) is None
|
||||
assert map_address(None) is None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue