Skip to content

Commit

Permalink
Add test case for route_geometry view: error 500
Browse files Browse the repository at this point in the history
  • Loading branch information
justinefricou committed Jul 9, 2024
1 parent d248327 commit 664b00b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions geotrek/core/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def test_delete_multiple_path(self):
self.assertEqual(Path.objects.filter(pk__in=[path_1.pk, path_2.pk]).count(), 0)


def get_route_exception_mock(steps):
raise Exception


@skipIf(not settings.TREKKING_TOPOLOGY_ENABLED, 'Test with dynamic segmentation only')
class PathViewsTest(CommonTest):
model = Path
Expand Down Expand Up @@ -684,6 +688,16 @@ def test_route_geometry_fail_incorrect_lng(self):
response = self.get_route_geometry({"steps": [{"lat": 48.866667, "lng": "abc"}, {"lat": 47.866667, "lng": 1.333333}]})
self.assertEqual(response.status_code, 400)

@mock.patch('geotrek.core.path_router.PathRouter.get_route', get_route_exception_mock)
def test_route_geometry_fail_error_500(self):
response = self.get_route_geometry({
"steps": [
{"lat": 40.5267991, "lng": 0.5305685},
{"lat": 40.5266465, "lng": 0.5765381}
]
})
self.assertEqual(response.status_code, 500)

def test_route_geometry_fail_steps_not_on_paths(self):
path_geom = LineString([
[1.3664246, 43.4569065],
Expand Down

0 comments on commit 664b00b

Please sign in to comment.