| 1 |
from responses import GET |
| 2 |
|
| 3 |
|
| 4 |
def test_capabilities(api, add_response): |
| 5 |
resp = add_response(GET, url="http://api06.dev.openstreetmap.org/api/capabilities") |
| 6 |
|
| 7 |
result = api.capabilities() |
| 8 |
|
| 9 |
assert resp.calls[0].request.method == "GET" |
| 10 |
assert ( |
| 11 |
resp.calls[0].request.url |
| 12 |
== "http://api06.dev.openstreetmap.org/api/capabilities" |
| 13 |
) |
| 14 |
assert result == { |
| 15 |
"area": {"maximum": 0.25}, |
| 16 |
"changesets": {"maximum_elements": 50000.0}, |
| 17 |
"status": {"api": "mocked", "database": "online", "gpx": "online"}, |
| 18 |
"timeout": {"seconds": 300.0}, |
| 19 |
"tracepoints": {"per_page": 5000.0}, |
| 20 |
"version": {"maximum": 0.6, "minimum": 0.6}, |
| 21 |
"waynodes": {"maximum": 2000.0}, |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
def test_map(api, add_response): |
| 26 |
resp = add_response(GET, "/map") |
| 27 |
|
| 28 |
result = api.map(8.765, 47.287, 8.767, 47.289) |
| 29 |
|
| 30 |
# the bbox is formatted with 6 decimal places |
| 31 |
assert resp.calls[0].request.url == ( |
| 32 |
"http://api06.dev.openstreetmap.org/api/0.6/map" |
| 33 |
"?bbox=8.765000,47.287000,8.767000,47.289000" |
| 34 |
) |
| 35 |
|
| 36 |
assert [elem["type"] for elem in result] == ["node", "node", "way", "relation"] |
| 37 |
assert result[0]["data"]["id"] == 11949 |
| 38 |
assert result[0]["data"]["lat"] == 47.2871 |
| 39 |
assert result[1]["data"]["tag"] == {"amenity": "bench"} |
| 40 |
assert result[2]["data"]["nd"] == [11949, 11950] |
| 41 |
assert result[3]["data"]["member"] == [{"ref": 321, "role": "outer", "type": "way"}] |
| 42 |
|
| 43 |
|
| 44 |
def test_map_negative_bbox(api, add_response): |
| 45 |
resp = add_response(GET, "/map", filename="test_map.xml") |
| 46 |
|
| 47 |
api.map(-1.5, -45.9667901, -1.4831815, 52.4710193) |
| 48 |
|
| 49 |
assert resp.calls[0].request.url == ( |
| 50 |
"http://api06.dev.openstreetmap.org/api/0.6/map" |
| 51 |
"?bbox=-1.500000,-45.966790,-1.483181,52.471019" |
| 52 |
) |
| 53 |
|
| 54 |
|
| 55 |
def test_map_empty(api, add_response): |
| 56 |
add_response(GET, "/map") |
| 57 |
|
| 58 |
result = api.map(8.765, 47.287, 8.7651, 47.2871) |
| 59 |
|
| 60 |
assert result == [] |