Skip to content

Commit

Permalink
fix ordered properties in ES provider (#1338)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis authored Aug 25, 2023
1 parent cba5563 commit fbd9209
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pygeoapi/provider/elasticsearch_.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,9 @@ def get_properties(self):
if not self.properties and not self.select_properties:
all_properties = self.get_fields()
if self.properties and self.select_properties:
all_properties = set(self.properties) & set(self.select_properties)
all_properties = self.properties and self.select_properties
else:
all_properties = set(self.properties) | set(self.select_properties)
all_properties = self.properties or self.select_properties

LOGGER.debug(f'resulting properties: {all_properties}')
return all_properties
Expand Down
23 changes: 23 additions & 0 deletions tests/test_elasticsearch__provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ def config():
}


@pytest.fixture()
def config_ordered_properties():
return {
'name': 'Elasticsearch',
'type': 'feature',
'data': 'http://localhost:9200/ne_110m_populated_places_simple', # noqa
'id_field': 'geonameid',
'properties': [
'adm0name',
'adm1name'
]
}


@pytest.fixture()
def config_cql():
return {
Expand Down Expand Up @@ -211,6 +225,15 @@ def test_query(config):
assert len(results['features'][0]['properties']) == 1


def test_query_ordered_properties(config_ordered_properties):
p = ElasticsearchProvider(config_ordered_properties)

result = p.query()
feature_properties = list(result['features'][0]['properties'].keys())

assert feature_properties == ['adm0name', 'adm1name']


def test_get(config):
p = ElasticsearchProvider(config)

Expand Down

0 comments on commit fbd9209

Please sign in to comment.