Skip to content

Commit

Permalink
Make the TNS and SSO resolver case-insensitive (#545)
Browse files Browse the repository at this point in the history
* Make the TNS and SSO resolver case-insensitive

* Add tests for lower cases
  • Loading branch information
JulienPeloton authored Dec 24, 2023
1 parent b5cbfac commit f7c1a0c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
7 changes: 4 additions & 3 deletions apps/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,8 @@ def return_resolver_pdf(payload: dict) -> pd.DataFrame:
0, False, False
)
else:
to_evaluate = "key:key:{}".format(name)
# indices are case-insensitive
to_evaluate = "key:key:{}".format(name.lower())
results = client.scan(
"",
to_evaluate,
Expand Down Expand Up @@ -1472,11 +1473,11 @@ def return_resolver_pdf(payload: dict) -> pd.DataFrame:

if nmax == 1:
# Prefix with internal marker
to_evaluate = "key:key:{}-".format(name)
to_evaluate = "key:key:{}-".format(name.lower())
elif nmax > 1:
# This enables e.g. autocompletion tasks
client.setLimit(nmax)
to_evaluate = "key:key:{}".format(name)
to_evaluate = "key:key:{}".format(name.lower())

results = client.scan(
"",
Expand Down
30 changes: 30 additions & 0 deletions tests/api_resolver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ def test_tns_resolver() -> None:
for col in cols:
assert col in pdf.columns, col

def test_tns_lower_case() -> None:
"""
Examples
---------
>>> test_tns_lower_case()
"""
pdf = resolver(resolver='tns', name='sn 2023')

# Not empty
assert not pdf.empty

# One object found
assert len(pdf) == 10

def test_reverse_tns_resolver() -> None:
"""
Examples
Expand Down Expand Up @@ -168,6 +182,22 @@ def test_ssodnet_resolver() -> None:

assert '2002MA06' in pdf['i:ssnamenr'].values, pdf

def test_ssodnet_lower_case() -> None:
"""
Examples
---------
>>> test_ssodnet_lower_case()
"""
pdf = resolver(resolver='ssodnet', name='julienpeloton')

# Not empty
assert not pdf.empty

# One object found
assert len(pdf) == 1, pdf

assert 'Julienpeloton' in pdf['i:name'].values, pdf

def test_reverse_ssodnet_resolver() -> None:
"""
Examples
Expand Down

0 comments on commit f7c1a0c

Please sign in to comment.