Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
raise_for_status #45, rm useless distance_matrix func
Browse files Browse the repository at this point in the history
  • Loading branch information
perrygeo committed Oct 26, 2015
1 parent 8fdff0d commit 5a958d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
14 changes: 4 additions & 10 deletions mapbox/services/distance.py
Expand Up @@ -22,13 +22,7 @@ def distances(self, features):
uri = URITemplate('%s/{profile}' % self.baseuri).expand(
profile=self.profile)

return self.session.post(uri, data=coords,
headers={'Content-Type': 'application/json'})

def distance_matrix(self, features):
res = self.distances(features)
if res.status_code == 200:
data = res.json()
return data['durations']
else:
raise Exception(res.text)
res = self.session.post(uri, data=coords,
headers={'Content-Type': 'application/json'})
res.raise_for_status()
return res
3 changes: 2 additions & 1 deletion tests/test_distances.py
Expand Up @@ -54,7 +54,8 @@ def test_distances_matrix():
status=200,
content_type='application/json')

matrix = mapbox.Distance(access_token='pk.test').distance_matrix(points)
res = mapbox.Distance(access_token='pk.test').distances(points)
matrix = res.json()['durations']
# 3x3 list
assert len(matrix) == 3
assert len(matrix[0]) == 3

0 comments on commit 5a958d0

Please sign in to comment.