import pytest
from etl.spatial.BoreholeClient import BoreholeClient


@pytest.fixture
def mock_borehole_data(monkeypatch):
    # Define the mock data to be returned by the read() method
    mock_data = [
        {
            'X': 464343.0,
            'Y': 415553.0
        },
        {
            'X': 464341.0,
            'Y': 415556.0
        },
        # Add more mock data entries here...
    ]

    # Monkeypatch the read() method to return the mock data
    def mock_read(self):
        return mock_data

    # Apply the monkeypatch to the BoreholeClient class
    monkeypatch.setattr(BoreholeClient, 'read', mock_read)


@pytest.mark.usefixtures('mock_borehole_data')
def test_distance_between_bng_coords():
    # Create an instance of BoreholeClient
    borehole_client = BoreholeClient("path/to/dbf/file")

    # Test the distance calculation
    distance_m, distance_km = borehole_client.distance_between_bng_coords(
        x1_bng=123456, y1_bng=789012, x2_bng=464343.0, y2_bng=415553.0
    )

    # Perform assertions to verify the results
    assert distance_m == 505643.71987596166
    assert distance_km == 505.64371987596166
