-
Notifications
You must be signed in to change notification settings - Fork 39
fix type for advanced freetext #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2fd8c8f
bb91b68
c0767f3
bbf0cb5
b5fdaba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no tests for the Also, there could be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe this PR is meant to implement free-text item search, just correct some stuff around free-text collection search. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
if you're passing a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Exactly, but it also enables free-text for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. Good point about the Pydantic model. I'm not sure to understand the " I was able to activate it is my implementation (https://github.com/crim-ca/stac-app/pull/28/files). It should do the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I just mean that As mentioned in #263 (comment) it works only for Advanced because we don't do |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -365,6 +365,71 @@ async def test_collection_search_freetext( | |
assert resp.json()["collections"][0]["id"] == load_test2_collection.id | ||
|
||
resp = await app_client.get( | ||
"/collections", | ||
params={"q": "temperature,calibrated"}, | ||
) | ||
assert resp.json()["numberReturned"] == 2 | ||
assert resp.json()["numberMatched"] == 2 | ||
assert len(resp.json()["collections"]) == 2 | ||
|
||
resp = await app_client.get( | ||
"/collections", | ||
params={"q": "temperature,yo"}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
) | ||
assert resp.json()["numberReturned"] == 1 | ||
assert resp.json()["numberMatched"] == 1 | ||
assert len(resp.json()["collections"]) == 1 | ||
assert resp.json()["collections"][0]["id"] == load_test2_collection.id | ||
|
||
resp = await app_client.get( | ||
"/collections", | ||
params={"q": "nosuchthing"}, | ||
) | ||
assert len(resp.json()["collections"]) == 0 | ||
|
||
|
||
@requires_pgstac_0_9_2 | ||
@pytest.mark.asyncio | ||
async def test_collection_search_freetext_advanced( | ||
app_client_advanced_freetext, load_test_collection, load_test2_collection | ||
): | ||
# free-text | ||
resp = await app_client_advanced_freetext.get( | ||
"/collections", | ||
params={"q": "temperature"}, | ||
) | ||
assert resp.json()["numberReturned"] == 1 | ||
assert resp.json()["numberMatched"] == 1 | ||
assert len(resp.json()["collections"]) == 1 | ||
assert resp.json()["collections"][0]["id"] == load_test2_collection.id | ||
|
||
resp = await app_client_advanced_freetext.get( | ||
"/collections", | ||
params={"q": "temperature,calibrated"}, | ||
) | ||
assert resp.json()["numberReturned"] == 2 | ||
assert resp.json()["numberMatched"] == 2 | ||
assert len(resp.json()["collections"]) == 2 | ||
|
||
resp = await app_client_advanced_freetext.get( | ||
"/collections", | ||
params={"q": "temperature,yo"}, | ||
) | ||
assert resp.json()["numberReturned"] == 1 | ||
assert resp.json()["numberMatched"] == 1 | ||
assert len(resp.json()["collections"]) == 1 | ||
assert resp.json()["collections"][0]["id"] == load_test2_collection.id | ||
|
||
resp = await app_client_advanced_freetext.get( | ||
"/collections", | ||
params={"q": "temperature OR yo"}, | ||
) | ||
assert resp.json()["numberReturned"] == 1 | ||
assert resp.json()["numberMatched"] == 1 | ||
assert len(resp.json()["collections"]) == 1 | ||
assert resp.json()["collections"][0]["id"] == load_test2_collection.id | ||
|
||
resp = await app_client_advanced_freetext.get( | ||
"/collections", | ||
params={"q": "nosuchthing"}, | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this PR we changed and we now forward
kwargs
to_clean_search_args
method.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if
POST /search
with{"q": 123}
is submitted? Doesq
make it all the way to the DB and raises due to invalid types? There won't be any early API model validation of the parameter?