Skip to content

Commit b77865a

Browse files
committed
hotfix and fix tests
1 parent eef03b6 commit b77865a

File tree

8 files changed

+33
-23
lines changed

8 files changed

+33
-23
lines changed

.pytest_cache/v/cache/lastfailed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

.pytest_cache/v/cache/nodeids

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[
2+
"tests/test_api.py::test_initialize_api",
3+
"tests/test_api.py::test_geojson"
4+
]

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Simplest example:
1818
```python
1919
import overpass
2020
api = overpass.API()
21-
response = api.Get('node["name"="Salt Lake City"]')
21+
response = api.get('node["name"="Salt Lake City"]')
2222
```
2323

2424
Note that you don't have to include any of the output meta statements.
@@ -37,7 +37,7 @@ print [(feature['tags']['name'], feature['id']) for feature in response['element
3737
You can specify the format of the response. By default, you will get GeoJSON using the `responseformat` parameter. Alternatives are plain JSON (`json`) and OSM XML (`xml`), as ouput directly by the Overpass API.
3838

3939
```python
40-
response = api.Get('node["name"="Salt Lake City"]', responseformat="xml")
40+
response = api.get('node["name"="Salt Lake City"]', responseformat="xml")
4141
```
4242

4343
### Parameters
@@ -81,8 +81,8 @@ query in a bounding box (the 'map call'). You just pass the bounding box
8181
to the constructor:
8282

8383
```python
84-
map_query = overpass.MapQuery(50.746,7.154,50.748,7.157)
85-
response = api.Get(map_query)
84+
MapQuery = overpass.MapQuery(50.746,7.154,50.748,7.157)
85+
response = api.get(MapQuery)
8686
```
8787

8888
#### WayQuery
@@ -92,8 +92,8 @@ satisfy certain criteria. Pass the criteria as a Overpass QL stub to the
9292
constructor:
9393

9494
```python
95-
way_query = overpass.WayQuery('[name="Highway 51"]')
96-
response = api.Get(way_query)
95+
WayQuery = overpass.WayQuery('[name="Highway 51"]')
96+
response = api.get(WayQuery)
9797
```
9898

9999
## Testing

examples/turn_restriction_relations_as_list.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99

1010
turn_restrictions_list = []
1111

12-
overpass_response = api.Get(
13-
turn_restrictions_query,
14-
responseformat='csv(::"id",::"user",::"timestamp",restriction,"restriction:conditional")',
15-
verbosity='meta')
12+
overpass_response = api.get(
13+
turn_restrictions_query,
14+
responseformat='csv(::"id",::"user",::"timestamp",restriction,"restriction:conditional")',
15+
verbosity='meta')
1616

1717
print(overpass_response)
18-
#reader = csv.reader(response)
19-
#turn_restrictions_list = list(reader)
18+
# reader = csv.reader(response)
19+
# turn_restrictions_list = list(reader)
2020

2121
for row in overpass_response.split('\n'):
22-
turn_restrictions_list.append([elem for elem in row.split('\t')])
22+
turn_restrictions_list.append([elem for elem in row.split('\t')])
2323

24-
print(turn_restrictions_list)
24+
print(turn_restrictions_list)

overpass/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
from .errors import (
1212
OverpassError, OverpassSyntaxError, TimeoutError, MultipleRequestsError, ServerLoadError, UnknownOverpassError
1313
)
14-
from .utils import *
14+
from .utils import *

overpass/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def get(self,
7777
elif content_type == "text/xml" or content_type == "application/xml":
7878
return r.text
7979

80-
response = json.loads(r)
80+
response = json.loads(r.text)
8181

8282
# Check for valid answer from Overpass.
8383
# A valid answer contains an 'elements' key at the root level.

overpass/queries.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class MapQuery(object):
99
def __init__(self, south, west, north, east):
1010
"""
1111
Initialize query with given bounding box.
12+
1213
:param bbox Bounding box with limit values in format west, south,
1314
east, north.
1415
"""
@@ -27,15 +28,15 @@ def __str__(self):
2728

2829

2930
class WayQuery(object):
30-
"""Query to retrieve a set of ways and their dependent nodes satisfying
31-
the input parameters"""
31+
"""Query to retrieve a set of ways and their dependent nodes satisfying the input parameters."""
3232

3333
_QUERY_TEMPLATE = "(way{query_parameters});(._;>;);"
3434

3535
def __init__(self, query_parameters):
3636
"""Initialize a query for a set of ways satisfying the given parameters.
37-
:param query_parameters Overpass QL query parameters"""
3837
38+
:param query_parameters Overpass QL query parameters
39+
"""
3940
self.query_parameters = query_parameters
4041

4142
def __str__(self):

tests/test_api.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ def test_initialize_api():
88

99

1010
def test_geojson():
11-
api = overpass.API()
11+
api = overpass.API(debug=True)
1212

13-
osm_geo = api.Get(
14-
overpass.MapQuery(37.86517, -122.31851, 37.86687, -122.31635))
13+
MapQuery = overpass.MapQuery(37.86517, -122.31851, 37.86687, -122.31635)
14+
print MapQuery
15+
osm_geo = api.get(MapQuery)
16+
print osm_geo
1517
assert len(osm_geo['features']) > 1
1618

17-
osm_geo = api.Get('node(area:3602758138)[amenity=cafe]')
19+
osm_geo = api.get('node(area:3602758138)[amenity=cafe]')
1820
assert len(osm_geo['features']) > 1
21+
22+
test_geojson()

0 commit comments

Comments
 (0)