Skip to content

Commit

Permalink
Jormungandr: update the test
Browse files Browse the repository at this point in the history
and return a nice error when no solution found
  • Loading branch information
antoine-de committed Jul 8, 2015
1 parent f72eb3d commit 3046ea8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion source/jormungandr/tests/authentication_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def test_unkown_region(self):
the authentication process must not mess if the region is not found
"""
with user_set(app, 'bob'):
r, status = self.query_no_assert('/v1/coverage/the_marvelous_unknown_region/stop_areas', display=True)
r, status = self.query_no_assert('/v1/coverage/the_marvelous_unknown_region/stop_areas')

assert status == 404
assert 'error' in r
Expand Down
32 changes: 19 additions & 13 deletions source/jormungandr/tests/isochrone_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,31 +62,37 @@ def test_stop_point_isochrone_coord(self):
assert response["journeys"][1]["to"]["stop_point"]["id"] == "D"

def test_to_isochrone_coord(self):
#NOTE: we query /v1/coverage/basic_routing_test/journeys and not directly /v1/journeys
#not to use the jormungandr database
query = "v1/coverage/basic_routing_test/journeys?from={}&datetime={}&datetime_represents=arrival"
query = "v1/coverage/basic_routing_test/journeys?from={}&datetime={}"
query = query.format(s_coord, "20120614T080000")
self.query(query)

def test_from_isochrone_sa(self):
#NOTE: we query /v1/coverage/basic_routing_test/journeys and not directly /v1/journeys
#not to use the jormungandr database
query = "v1/coverage/basic_routing_test/journeys?from={}&datetime={}"
query = query.format("stopA", "20120614T080000")
self.query(query)

def test_to_isochrone_sa(self):
#NOTE: we query /v1/coverage/basic_routing_test/journeys and not directly /v1/journeys
#not to use the jormungandr database
query = "v1/coverage/basic_routing_test/journeys?from={}&datetime={}&datetime_represents=arrival"
query = "v1/coverage/basic_routing_test/journeys?to={}&datetime={}&datetime_represents=arrival"
query = query.format("stopA", "20120614T080000")
self.query(query)

def test_reverse_isochrone_coord(self):
q = "v1/coverage/basic_routing_test/journeys?max_duration=25500&datetime=20120614T080000"
normal_response = self.query(q + "&from=A")
q = "v1/coverage/basic_routing_test/journeys?max_duration=100000" \
"&datetime=20120615T200000&datetime_represents=arrival&to=D"
normal_response = self.query(q, display=True)
assert len(normal_response["journeys"]) == 2

# the reverse isochrone should also find 2 journeys
normal_response = self.query(q + "&to=A")
assert len(normal_response["journeys"]) == 2
def test_reverse_isochrone_coord_clockwise(self):
q = "v1/coverage/basic_routing_test/journeys?datetime=20120614T080000&to=A"
normal_response, error_code = self.query_no_assert(q)

assert error_code == 404
assert normal_response['error']['message'] == 'reverse isochrone works only for anti-clockwise request'


def test_isochrone_non_clockwise(self):
q = "v1/coverage/basic_routing_test/journeys?datetime=20120614T080000&from=A&datetime_represents=arrival"
normal_response, error_code = self.query_no_assert(q)

assert error_code == 404
assert normal_response['error']['message'] == 'isochrone works only for clockwise request'
6 changes: 6 additions & 0 deletions source/routing/raptor_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,12 @@ pbnavitia::Response make_isochrone(RAPTOR &raptor,
return journey1.destination().uri() < journey2.destination().uri();
});

if (response.journeys().size() == 0) {
fill_pb_error(pbnavitia::Error::no_solution, "no solution found for this isochrone",
response.mutable_error());
response.set_response_type(pbnavitia::NO_SOLUTION);
}


return response;
}
Expand Down

0 comments on commit 3046ea8

Please sign in to comment.