mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Added borehole tests
This commit is contained in:
parent
148bd5e857
commit
ccc4610b18
2 changed files with 40 additions and 1 deletions
|
|
@ -45,7 +45,6 @@ class BoreholeClient:
|
|||
logger.info("Reading in borehole data")
|
||||
table = DBF(self.path)
|
||||
borehole_data = [x for x in tqdm(table, total=len(table))]
|
||||
|
||||
self.data = borehole_data
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
40
model_data/tests/test_borehole_client.py
Normal file
40
model_data/tests/test_borehole_client.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
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 == 123.45
|
||||
assert distance_km == 0.12345
|
||||
Loading…
Add table
Reference in a new issue