import os

import pytest

from datatypes.epc.loaders.historic_epc import read_historic_epc_csv
from datatypes.epc.domain.historic_epc import HistoricEpc

FIXTURES = os.path.join(os.path.dirname(__file__), "fixtures")


class TestHistoricEpcLoading:

    @pytest.fixture
    def epc(self) -> HistoricEpc:
        rows = read_historic_epc_csv(os.path.join(FIXTURES, "historic_epc.csv"))
        return rows[0]

    def test_returns_historic_epc_instance(self, epc: HistoricEpc) -> None:
        assert isinstance(epc, HistoricEpc)

    def test_lmk_key(self, epc: HistoricEpc) -> None:
        assert epc.lmk_key == "9292c3bf26a8876ce59274401ea73e3de5bd0b3e52a507c2162a46e57db8ea2f"

    def test_address1(self, epc: HistoricEpc) -> None:
        assert epc.address1 == "47 GORDON ROAD"

    def test_postcode(self, epc: HistoricEpc) -> None:
        assert epc.postcode == "AB33 8AL"

    def test_current_energy_rating(self, epc: HistoricEpc) -> None:
        assert epc.current_energy_rating == "E"

    def test_property_type(self, epc: HistoricEpc) -> None:
        assert epc.property_type == "House"

    def test_built_form(self, epc: HistoricEpc) -> None:
        assert epc.built_form == "Semi-Detached"

    def test_inspection_date(self, epc: HistoricEpc) -> None:
        assert epc.inspection_date == "2021-04-11"

    def test_uprn(self, epc: HistoricEpc) -> None:
        assert epc.uprn == "151020766.0"

    def test_uprn_source(self, epc: HistoricEpc) -> None:
        assert epc.uprn_source == "Energy Assessor"

    def test_report_type(self, epc: HistoricEpc) -> None:
        assert epc.report_type == "100"
