@@ -211,7 +211,8 @@ async def test_search_filter(item_descriptions,
211211
212212 cl = DataClient (session , base_url = TEST_URL )
213213 items_list = [
214- i async for i in cl .search (['PSScene' ], search_filter = search_filter )
214+ i async for i in cl .search (item_types = ['PSScene' ],
215+ search_filter = search_filter )
215216 ]
216217
217218 # check that request is correct
@@ -223,6 +224,35 @@ async def test_search_filter(item_descriptions,
223224 assert items_list == item_descriptions
224225
225226
227+ @respx .mock
228+ @pytest .mark .anyio
229+ async def test_search_filter_positional_args (item_descriptions ,
230+ search_filter ,
231+ search_response ,
232+ session ):
233+ """test the search method using positional args"""
234+
235+ quick_search_url = f'{ TEST_URL } /quick-search'
236+
237+ item1 , item2 , item3 = item_descriptions
238+ response = {"features" : [item1 , item2 , item3 ]}
239+ mock_resp = httpx .Response (HTTPStatus .OK , json = response )
240+ respx .post (quick_search_url ).return_value = mock_resp
241+
242+ cl = DataClient (session , base_url = TEST_URL )
243+
244+ # search using a positional arg for the filter.
245+ items_list = [i async for i in cl .search (['PSScene' ], search_filter )]
246+
247+ # check that request is correct
248+ expected_request = {"item_types" : ["PSScene" ], "filter" : search_filter }
249+ actual_body = json .loads (respx .calls [0 ].request .content )
250+ assert actual_body == expected_request
251+
252+ # check that all of the items were returned unchanged
253+ assert items_list == item_descriptions
254+
255+
226256@respx .mock
227257@pytest .mark .anyio
228258async def test_search_sort (item_descriptions ,
@@ -295,7 +325,7 @@ async def test_create_search_basic(search_filter, session):
295325 respx .post (TEST_SEARCHES_URL ).return_value = mock_resp
296326
297327 cl = DataClient (session , base_url = TEST_URL )
298- search = await cl .create_search (['PSScene' ],
328+ search = await cl .create_search (item_types = ['PSScene' ],
299329 search_filter = search_filter ,
300330 name = 'test' )
301331
@@ -313,6 +343,43 @@ async def test_create_search_basic(search_filter, session):
313343 assert search == page_response
314344
315345
346+ @respx .mock
347+ @pytest .mark .anyio
348+ async def test_create_search_basic_positional_args (search_filter , session ):
349+ """Test that positional arguments are accepted for create_search"""
350+
351+ page_response = {
352+ "__daily_email_enabled" : False ,
353+ "_links" : {
354+ "_self" : "string" , "thumbnail" : "string"
355+ },
356+ "created" : "2019-08-24T14:15:22Z" ,
357+ "filter" : search_filter ,
358+ "id" : "string" ,
359+ "last_executed" : "2019-08-24T14:15:22Z" ,
360+ "name" : "test" ,
361+ "updated" : "2019-08-24T14:15:22Z"
362+ }
363+ mock_resp = httpx .Response (HTTPStatus .OK , json = page_response )
364+ respx .post (TEST_SEARCHES_URL ).return_value = mock_resp
365+
366+ cl = DataClient (session , base_url = TEST_URL )
367+ search = await cl .create_search (['PSScene' ], search_filter , name = 'test' )
368+
369+ # check that request is correct
370+ expected_request = {
371+ "item_types" : ["PSScene" ],
372+ "filter" : search_filter ,
373+ "name" : "test" ,
374+ "__daily_email_enabled" : False
375+ }
376+ actual_body = json .loads (respx .calls [0 ].request .content )
377+ assert actual_body == expected_request
378+
379+ # check the response is returned unaltered
380+ assert search == page_response
381+
382+
316383@respx .mock
317384@pytest .mark .anyio
318385async def test_create_search_email (search_filter , session ):
@@ -420,6 +487,46 @@ async def test_update_search_basic(search_filter, session):
420487 assert search == page_response
421488
422489
490+ @respx .mock
491+ @pytest .mark .anyio
492+ async def test_update_search_basic_positional_args (search_filter , session ):
493+ """Test that positional arguments are accepted for update_search"""
494+
495+ page_response = {
496+ "__daily_email_enabled" : False ,
497+ "_links" : {
498+ "_self" : "string" , "thumbnail" : "string"
499+ },
500+ "created" : "2019-08-24T14:15:22Z" ,
501+ "filter" : search_filter ,
502+ "id" : VALID_SEARCH_ID ,
503+ "last_executed" : "2019-08-24T14:15:22Z" ,
504+ "name" : "test" ,
505+ "updated" : "2019-08-24T14:15:22Z"
506+ }
507+ mock_resp = httpx .Response (HTTPStatus .OK , json = page_response )
508+ respx .put (
509+ f'{ TEST_SEARCHES_URL } /{ VALID_SEARCH_ID } ' ).return_value = mock_resp
510+
511+ cl = DataClient (session , base_url = TEST_URL )
512+ search = await cl .update_search (VALID_SEARCH_ID , ['PSScene' ],
513+ search_filter ,
514+ name = 'test' )
515+
516+ # check that request is correct
517+ expected_request = {
518+ "item_types" : ["PSScene" ],
519+ "filter" : search_filter ,
520+ "name" : "test" ,
521+ "__daily_email_enabled" : False
522+ }
523+ actual_body = json .loads (respx .calls [0 ].request .content )
524+ assert actual_body == expected_request
525+
526+ # check the response is returned unaltered
527+ assert search == page_response
528+
529+
423530@respx .mock
424531@pytest .mark .anyio
425532@pytest .mark .parametrize ("limit, expected_list_length" , [(None , 4 ), (3 , 3 )])
0 commit comments