# Path: OSMPythonTools/api.py
# class Api(CacheObject):
#     def __init__(self, endpoint='http://www.openstreetmap.org/api/0.6/', **kwargs):
#         super().__init__('api', endpoint, jsonResult=False, **kwargs)
#     
#     def _queryString(self, query, params={}, history=False):
#         query = query + ('/history' if history else '')
#         return (query, query, params)
#     
#     def _queryRequest(self, endpoint, queryString, params={}):
#         return endpoint + queryString
#     
#     def _rawToResult(self, data, queryString, params, kwargs, cacheMetadata=None, shallow=False):
#         return ApiResult(data, queryString, params, cacheMetadata=cacheMetadata, shallow=shallow, history=kwargs['history'] if 'history' in kwargs else False)


from OSMPythonTools.api import Api
  api = Api()
  x = api.query('way/108402486')
  assert x.isValid()
  assert x.id() == 108402486
  assert x.type() == 'way'
  assert len(x.nodes()) > 0
  assert 1243967857 in [n.id() for n in x.nodes()]
  assert abs(x.nodes()[0].lat() - 40.866) < .01
  assert abs(x.nodes()[0].lon() - (-73.795)) < .01
  assert abs(x.nodes(shallow=False)[1].lat() - 40.866) < .01
  assert abs(x.nodes(shallow=False)[1].lon() - (-73.795)) < .01
  assert int(x.version()) > 0
  metadata(x)

def test_relation():
  api = Api()
  x = api.query('relation/1539714')
  assert x.isValid()
  assert x.id() == 1539714
  assert x.type() == 'relation'
  assert len(x.members()) > 0
  assert 108402486 in [n.id() for n in x.members()]
  assert abs(x.members()[0].nodes()[0].lat() - 40.866) < .01
  assert abs(x.members()[0].nodes()[0].lon() - (-73.795)) < .01
  assert abs(x.members(shallow=False)[1].nodes()[0].lat() - 40.866) < .01
  assert abs(x.members(shallow=False)[1].nodes()[0].lon() - (-73.795)) < .01
  assert int(x.version()) > 0
  metadata(x)

def test_history():

# Path: OSMPythonTools/api.py
# class Api(CacheObject):
#     def __init__(self, endpoint='http://www.openstreetmap.org/api/0.6/', **kwargs):
#         super().__init__('api', endpoint, jsonResult=False, **kwargs)
#     
#     def _queryString(self, query, params={}, history=False):
#         query = query + ('/history' if history else '')
#         return (query, query, params)
#     
#     def _queryRequest(self, endpoint, queryString, params={}):
#         return endpoint + queryString
#     
#     def _rawToResult(self, data, queryString, params, kwargs, cacheMetadata=None, shallow=False):
#         return ApiResult(data, queryString, params, cacheMetadata=cacheMetadata, shallow=shallow, history=kwargs['history'] if 'history' in kwargs else False)


# Path: tests/test_api.py
from OSMPythonTools.api import Api

  api = Api()
  x = api.query('way/108402486')
  assert x.isValid()
  assert x.id() == 108402486
  assert x.type() == 'way'
  assert len(x.nodes()) > 0
  assert 1243967857 in [n.id() for n in x.nodes()]
  assert abs(x.nodes()[0].lat() - 40.866) < .01
  assert abs(x.nodes()[0].lon() - (-73.795)) < .01
  assert abs(x.nodes(shallow=False)[1].lat() - 40.866) < .01
  assert abs(x.nodes(shallow=False)[1].lon() - (-73.795)) < .01
  assert int(x.version()) > 0
  metadata(x)

def test_relation():
  api = Api()
  x = api.query('relation/1539714')
  assert x.isValid()
  assert x.id() == 1539714
  assert x.type() == 'relation'
  assert len(x.members()) > 0
  assert 108402486 in [n.id() for n in x.members()]
  assert abs(x.members()[0].nodes()[0].lat() - 40.866) < .01
  assert abs(x.members()[0].nodes()[0].lon() - (-73.795)) < .01
  assert abs(x.members(shallow=False)[1].nodes()[0].lat() - 40.866) < .01
  assert abs(x.members(shallow=False)[1].nodes()[0].lon() - (-73.795)) < .01
  assert int(x.version()) > 0
  metadata(x)

def test_history():

  api = Api()