Skip to content

Commit be7d980

Browse files
authored
Merge pull request #510 from ror-community/dev
2 parents eab9afa + 17ebe9e commit be7d980

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ sentry-sdk==0.12.2
1313
python-dotenv==0.10.3
1414
django-cors-headers==3.1.0
1515
unidecode==1.1.1
16-
fuzzywuzzy==0.17.0
16+
fuzzywuzzy==0.18.0
1717
python-Levenshtein==0.12.1
1818
statsmodels==0.10.2
1919
boto3

rorapi/common/queries.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ def build_search_query(params, version):
308308
]
309309
# normalize filter values based on casing conventions used in ROR records
310310
for f in filters:
311+
f[1] = " ".join(f[1].split())
311312
if f[0] == "types":
312313
if version == "v2":
313314
f[1] = f[1].lower()

rorapi/tests/tests_unit/tests_queries_v2.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,20 @@ def test_filter_status_filter(self):
370370
query = build_search_query({'filter': f}, self.V2_VERSION)
371371
self.assertEquals(query.to_dict(), expected)
372372

373+
def test_filter_whitespace_normalization(self):
374+
f = 'locations.geonames_details.country_name:South Africa'
375+
expected = {'query': {
376+
'bool': {
377+
'filter': [
378+
{'terms': {'locations.geonames_details.country_name': ('South Africa',)}},
379+
{'terms': {'status': ['active']}}
380+
],
381+
}
382+
}}
383+
expected.update(self.default_query)
384+
query = build_search_query({'filter': f}, self.V2_VERSION)
385+
self.assertEquals(query.to_dict(), expected)
386+
373387
def test_filter_all_status(self):
374388
f = 'key1:val1,k2:value2'
375389
expected = {'query': {

0 commit comments

Comments
 (0)