From 9d0eed591542d5f41e841fdc55b6208a3abd8641 Mon Sep 17 00:00:00 2001 From: moanos Date: Wed, 1 Jan 2025 18:59:01 +0100 Subject: [PATCH] test: Add e2e test for distance --- src/tests/test_geo.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/tests/test_geo.py b/src/tests/test_geo.py index 520c1c3..584e185 100644 --- a/src/tests/test_geo.py +++ b/src/tests/test_geo.py @@ -1,4 +1,4 @@ -from fellchensammlung.tools.geo import calculate_distance_between_coordinates +from fellchensammlung.tools.geo import calculate_distance_between_coordinates, LocationProxy from django.test import TestCase @@ -22,3 +22,22 @@ class DistanceTest(TestCase): except AssertionError as e: print(f"Distance calculation failed. Expected {distance}, got {result}") raise e + + def test_e2e_distance(self): + l_stuttgart = LocationProxy("Stuttgart") + l_tue = LocationProxy("Tübingen") + # Should be 30km + print(f"{l_stuttgart.position} -> {l_tue.position}") + distance_tue_stuttgart = calculate_distance_between_coordinates(l_stuttgart.position, l_tue.position) + self.assertLess(distance_tue_stuttgart, 50) + self.assertGreater(distance_tue_stuttgart, 20) + + + l_ueberlingen = LocationProxy("Überlingen") + l_pfullendorf = LocationProxy("Pfullendorf") + # Should be 18km + distance_ueberlingen_pfullendorf = calculate_distance_between_coordinates(l_stuttgart.position, l_tue.position) + self.assertLess(distance_tue_stuttgart, 21) + self.assertGreaer(distance_tue_stuttgart, 15) + +