import json
import pathlib
import pytest

from backend.epc_client.epc_client_service import EpcClientService

SAMPLES_DIR = pathlib.Path("backend/epc_api/json_samples")


@pytest.fixture
def rdsap_21_0_0_cert():
    return json.loads((SAMPLES_DIR / "RdSAP-Schema-21.0.0/epc.json").read_text())


@pytest.fixture
def rdsap_21_0_1_cert():
    return json.loads((SAMPLES_DIR / "RdSAP-Schema-21.0.1/epc.json").read_text())


@pytest.fixture
def epc_service():
    return EpcClientService(auth_token="test-token")


def make_search_row(
    cert_num="CERT-001",
    address_line_1="1 Test Street",
    postcode="SW1A 1AA",
    post_town="London",
    uprn=100023336956,
    band="D",
    registration_date="2024-01-01",
    address_line_2=None,
    address_line_3=None,
    address_line_4=None,
):
    return {
        "certificateNumber": cert_num,
        "addressLine1": address_line_1,
        "addressLine2": address_line_2,
        "addressLine3": address_line_3,
        "addressLine4": address_line_4,
        "postcode": postcode,
        "postTown": post_town,
        "uprn": uprn,
        "currentEnergyEfficiencyBand": band,
        "registrationDate": registration_date,
    }
