diff --git a/model_data/BoreholeClient.py b/model_data/BoreholeClient.py index f268d6a7..4212d94b 100644 --- a/model_data/BoreholeClient.py +++ b/model_data/BoreholeClient.py @@ -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 diff --git a/model_data/tests/test_borehole_client.py b/model_data/tests/test_borehole_client.py new file mode 100644 index 00000000..eb596ae4 --- /dev/null +++ b/model_data/tests/test_borehole_client.py @@ -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