Model/model_data/tests/test_borehole_client.py
Khalim Conn-Kowlessar 7d30978caa replace silly results
2023-06-19 20:33:34 +01:00

40 lines
1.1 KiB
Python

import pytest
from model_data.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