"""
import json
import xml.etree.ElementTree as ET
-from pathlib import Path
import pytest
err = self.run_raise_error('TEST', 404)
assert self.adaptor.content_type == 'text/plain; charset=utf-8'
- assert err.msg == 'TEST'
+ assert err.msg == 'ERROR 404: TEST'
assert err.status == 404
a = FakeAdaptor()
self.status = napi.StatusResult(0, 'foo')
- resp = await glue.status_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ resp = await glue.status_endpoint(napi.NominatimAPIAsync(), a)
assert isinstance(resp, FakeResponse)
assert resp.status == 200
a = FakeAdaptor()
self.status = napi.StatusResult(405, 'foo')
- resp = await glue.status_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ resp = await glue.status_endpoint(napi.NominatimAPIAsync(), a)
assert isinstance(resp, FakeResponse)
assert resp.status == 500
a = FakeAdaptor(params={'format': 'json'})
self.status = napi.StatusResult(405, 'foo')
- resp = await glue.status_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ resp = await glue.status_endpoint(napi.NominatimAPIAsync(), a)
assert isinstance(resp, FakeResponse)
assert resp.status == 200
self.status = napi.StatusResult(0, 'foo')
with pytest.raises(FakeError):
- await glue.status_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ await glue.status_endpoint(napi.NominatimAPIAsync(), a)
# details_endpoint()
a = FakeAdaptor()
with pytest.raises(FakeError, match='^400 -- .*Missing'):
- await glue.details_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ await glue.details_endpoint(napi.NominatimAPIAsync(), a)
@pytest.mark.asyncio
async def test_details_by_place_id(self):
a = FakeAdaptor(params={'place_id': '4573'})
- await glue.details_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ await glue.details_endpoint(napi.NominatimAPIAsync(), a)
assert self.lookup_args[0].place_id == 4573
async def test_details_by_osm_id(self):
a = FakeAdaptor(params={'osmtype': 'N', 'osmid': '45'})
- await glue.details_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ await glue.details_endpoint(napi.NominatimAPIAsync(), a)
assert self.lookup_args[0].osm_type == 'N'
assert self.lookup_args[0].osm_id == 45
async def test_details_with_debugging(self):
a = FakeAdaptor(params={'osmtype': 'N', 'osmid': '45', 'debug': '1'})
- resp = await glue.details_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ resp = await glue.details_endpoint(napi.NominatimAPIAsync(), a)
content = ET.fromstring(resp.output)
assert resp.content_type == 'text/html; charset=utf-8'
self.result = None
with pytest.raises(FakeError, match='^404 -- .*found'):
- await glue.details_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ await glue.details_endpoint(napi.NominatimAPIAsync(), a)
# reverse_endpoint()
a.params['format'] = 'xml'
with pytest.raises(FakeError, match='^400 -- (?s:.*)missing'):
- await glue.reverse_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ await glue.reverse_endpoint(napi.NominatimAPIAsync(), a)
@pytest.mark.asyncio
a.params = params
a.params['format'] = 'json'
- res = await glue.reverse_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ res = await glue.reverse_endpoint(napi.NominatimAPIAsync(), a)
assert res == ''
a.params['lat'] = '56.3'
a.params['lon'] = '6.8'
- assert await glue.reverse_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ assert await glue.reverse_endpoint(napi.NominatimAPIAsync(), a)
@pytest.mark.asyncio
a.params['q'] = '34.6 2.56'
a.params['format'] = 'json'
- res = await glue.search_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ res = await glue.search_endpoint(napi.NominatimAPIAsync(), a)
assert len(json.loads(res.output)) == 1
a = FakeAdaptor()
a.params['format'] = 'json'
- res = await glue.lookup_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ res = await glue.lookup_endpoint(napi.NominatimAPIAsync(), a)
assert res.output == '[]'
a.params['format'] = 'json'
a.params['osm_ids'] = f'W34,{param},N33333'
- res = await glue.lookup_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ res = await glue.lookup_endpoint(napi.NominatimAPIAsync(), a)
assert len(json.loads(res.output)) == 1
a.params['format'] = 'json'
a.params['osm_ids'] = f'W34,{param},N33333'
- res = await glue.lookup_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ res = await glue.lookup_endpoint(napi.NominatimAPIAsync(), a)
assert len(json.loads(res.output)) == 1
a.params['format'] = 'json'
a.params['osm_ids'] = 'N23,W34'
- res = await glue.lookup_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ res = await glue.lookup_endpoint(napi.NominatimAPIAsync(), a)
assert len(json.loads(res.output)) == 1
a = FakeAdaptor()
a.params['q'] = 'something'
- res = await glue.search_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ res = await glue.search_endpoint(napi.NominatimAPIAsync(), a)
assert len(json.loads(res.output)) == 1
a.params['q'] = 'something'
a.params['format'] = 'xml'
- res = await glue.search_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ res = await glue.search_endpoint(napi.NominatimAPIAsync(), a)
assert res.status == 200
assert res.output.index('something') > 0
a.params['city'] = 'ignored'
with pytest.raises(FakeError, match='^400 -- .*cannot be used together'):
- res = await glue.search_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ res = await glue.search_endpoint(napi.NominatimAPIAsync(), a)
@pytest.mark.asyncio
if not dedupe:
a.params['dedupe'] = '0'
- res = await glue.search_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ res = await glue.search_endpoint(napi.NominatimAPIAsync(), a)
assert len(json.loads(res.output)) == numres
a = FakeAdaptor()
a.params['street'] = 'something'
- res = await glue.search_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ res = await glue.search_endpoint(napi.NominatimAPIAsync(), a)
assert len(json.loads(res.output)) == 1
a = FakeAdaptor()
a.params['q'] = '[shop=fog]'
- res = await glue.search_endpoint(napi.NominatimAPIAsync(Path('/invalid')), a)
+ res = await glue.search_endpoint(napi.NominatimAPIAsync(), a)
assert len(json.loads(res.output)) == 1