fix numberReturned response property
This commit is contained in:
@@ -98,7 +98,9 @@ class CSVProvider(BaseProvider):
|
||||
elif identifier is not None and found:
|
||||
return result
|
||||
|
||||
feature_collection['numberReturned'] = limit
|
||||
feature_collection['numberReturned'] = len(
|
||||
feature_collection['features'])
|
||||
|
||||
return feature_collection
|
||||
|
||||
def query(self, startindex=0, limit=10, resulttype='results',
|
||||
|
||||
@@ -191,7 +191,7 @@ class ElasticsearchProvider(BaseProvider):
|
||||
if resulttype == 'hits':
|
||||
return feature_collection
|
||||
|
||||
feature_collection['numberReturned'] = limit
|
||||
feature_collection['numberReturned'] = len(results['hits']['hits'])
|
||||
|
||||
LOGGER.debug('serializing features')
|
||||
for feature in results['hits']['hits']:
|
||||
|
||||
@@ -111,8 +111,8 @@ class GeoJSONProvider(BaseProvider):
|
||||
if resulttype == 'hits':
|
||||
data['features'] = []
|
||||
else:
|
||||
data['numberReturned'] = limit
|
||||
data['features'] = data['features'][startindex:startindex+limit]
|
||||
data['numberReturned'] = len(data['features'])
|
||||
|
||||
return data
|
||||
|
||||
|
||||
@@ -62,6 +62,8 @@ def test_query(fixture, config):
|
||||
p = CSVProvider(config)
|
||||
results = p.query()
|
||||
assert len(results['features']) == 5
|
||||
assert results['numberMatched'] == 5
|
||||
assert results['numberReturned'] == 5
|
||||
assert results['features'][0]['ID'] == '371'
|
||||
assert results['features'][0]['properties']['value'] == '89.9'
|
||||
|
||||
|
||||
@@ -45,9 +45,16 @@ def test_query(config):
|
||||
p = ElasticsearchProvider(config)
|
||||
results = p.query()
|
||||
assert len(results['features']) == 10
|
||||
assert results['numberMatched'] == 242
|
||||
assert results['numberReturned'] == 10
|
||||
assert results['features'][0]['ID'] == 6691831
|
||||
assert results['features'][0]['properties']['nameascii'] == 'Vatican City'
|
||||
|
||||
results = p.query(properties=[('nameascii', 'Vatican City')])
|
||||
assert len(results['features']) == 4
|
||||
assert results['numberMatched'] == 4
|
||||
assert results['numberReturned'] == 4
|
||||
|
||||
results = p.query(limit=1)
|
||||
assert len(results['features']) == 1
|
||||
assert results['features'][0]['ID'] == 6691831
|
||||
|
||||
@@ -38,6 +38,8 @@ def test_query(fixture, config):
|
||||
p = GeoJSONProvider(config)
|
||||
results = p.query()
|
||||
assert len(results['features']) == 1
|
||||
assert results['numberMatched'] == 1
|
||||
assert results['numberReturned'] == 1
|
||||
assert results['features'][0]['properties']['id'] == '123-456'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user