Skip to content

Commit edfa650

Browse files
add a test using positional args
1 parent dc032e5 commit edfa650

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ coverage.xml
2626
.vscode/
2727
# Docs build
2828
site
29+
.venv

tests/integration/test_data_api.py

+37
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,43 @@ async def test_search_filter(item_descriptions,
223223
assert items_list == item_descriptions
224224

225225

226+
@respx.mock
227+
@pytest.mark.anyio
228+
async def test_search_filter_positional_args(item_descriptions,
229+
search_filter,
230+
search_response,
231+
session):
232+
233+
quick_search_url = f'{TEST_URL}/quick-search'
234+
next_page_url = f'{TEST_URL}/blob/?page_marker=IAmATest'
235+
236+
item1, item2, item3 = item_descriptions
237+
page1_response = {
238+
"_links": {
239+
"_next": next_page_url
240+
}, "features": [item1, item2]
241+
}
242+
mock_resp1 = httpx.Response(HTTPStatus.OK, json=page1_response)
243+
respx.post(quick_search_url).return_value = mock_resp1
244+
245+
page2_response = {"_links": {"_self": next_page_url}, "features": [item3]}
246+
mock_resp2 = httpx.Response(HTTPStatus.OK, json=page2_response)
247+
respx.get(next_page_url).return_value = mock_resp2
248+
249+
cl = DataClient(session, base_url=TEST_URL)
250+
251+
# search using a positional arg for the filter.
252+
items_list = [i async for i in cl.search(['PSScene'], search_filter)]
253+
254+
# check that request is correct
255+
expected_request = {"item_types": ["PSScene"], "filter": search_filter}
256+
actual_body = json.loads(respx.calls[0].request.content)
257+
assert actual_body == expected_request
258+
259+
# check that all of the items were returned unchanged
260+
assert items_list == item_descriptions
261+
262+
226263
@respx.mock
227264
@pytest.mark.anyio
228265
async def test_search_sort(item_descriptions,

0 commit comments

Comments
 (0)