@@ -12,14 +12,24 @@ def search_query():
1212 return 'myquery'
1313
1414
15- @pytest .fixture
16- def search_limit ():
17- return 20
15+ @pytest .fixture ( params = ( 1 , 20 , 100 ))
16+ def search_limit (request ):
17+ return request . param
1818
1919
20- @pytest .fixture
21- def search_offset ():
22- return 0
20+ @pytest .fixture (params = (0 , 10 ))
21+ def search_offset (request ):
22+ return request .param
23+
24+
25+ @pytest .fixture (params = (None , 'file' , 'folder' ))
26+ def search_result_type (request ):
27+ return request .param
28+
29+
30+ @pytest .fixture (params = (None , ('name' ,), ('name' , 'description' )))
31+ def search_content_types (request ):
32+ return request .param
2333
2434
2535@pytest .fixture
@@ -81,6 +91,8 @@ def compare_params(self, other):
8191 if json .loads (self ['mdfilters' ]) != json .loads (other ['mdfilters' ]):
8292 return False
8393 # For other keys, just ensure that they are equal
94+ elif key in ('type' , 'content_types' ):
95+ return self [key ] is None or self [key ] == other [key ]
8496 else :
8597 if self [key ] != other [key ]:
8698 return False
@@ -96,20 +108,31 @@ def test_search_with_value_based_filters(
96108 search_offset ,
97109 search_value_based_filters ,
98110 search_response ,
99- search_entries
111+ search_entries ,
112+ search_result_type ,
113+ search_content_types ,
100114):
101115 # pylint:disable=redefined-outer-name
102116 mock_box_session .get .return_value , _ = make_mock_box_request (response = search_response )
103- response = test_search .search (search_query , limit = search_limit , offset = search_offset , metadata_filters = search_value_based_filters )
117+ response = test_search .search (
118+ search_query ,
119+ limit = search_limit ,
120+ offset = search_offset ,
121+ metadata_filters = search_value_based_filters ,
122+ result_type = search_result_type ,
123+ content_types = search_content_types ,
124+ )
104125 assert response == [File (mock_box_session , search_entry ['id' ], search_entry ) for search_entry in search_entries ]
105126
106127 mock_box_session .get .assert_called_once_with (
107128 test_search .get_url (),
108129 params = Matcher (compare_params , {
109- 'query' : 'myquery' ,
110- 'limit' : 20 ,
130+ 'query' : search_query ,
131+ 'limit' : search_limit ,
111132 'mdfilters' : json .dumps (search_value_based_filters .as_list ()),
112- 'offset' : 0
133+ 'offset' : search_offset ,
134+ 'type' : search_result_type ,
135+ 'content_types' : ',' .join (search_content_types ) if search_content_types else search_content_types ,
113136 })
114137 )
115138
@@ -123,20 +146,31 @@ def test_search_with_range_filters(
123146 search_offset ,
124147 search_range_filters ,
125148 search_response ,
126- search_entries
149+ search_entries ,
150+ search_result_type ,
151+ search_content_types ,
127152):
128153 # pylint:disable=redefined-outer-name
129154 mock_box_session .get .return_value , _ = make_mock_box_request (response = search_response )
130- response = test_search .search (search_query , limit = search_limit , offset = search_offset , metadata_filters = search_range_filters )
155+ response = test_search .search (
156+ search_query ,
157+ limit = search_limit ,
158+ offset = search_offset ,
159+ metadata_filters = search_range_filters ,
160+ result_type = search_result_type ,
161+ content_types = search_content_types ,
162+ )
131163 assert response == [File (mock_box_session , search_entry ['id' ], search_entry ) for search_entry in search_entries ]
132164
133165 mock_box_session .get .assert_called_once_with (
134166 test_search .get_url (),
135167 params = Matcher (compare_params , {
136- 'query' : 'myquery' ,
137- 'limit' : 20 ,
168+ 'query' : search_query ,
169+ 'limit' : search_limit ,
138170 'mdfilters' : json .dumps (search_range_filters .as_list ()),
139- 'offset' : 0
171+ 'offset' : search_offset ,
172+ 'type' : search_result_type ,
173+ 'content_types' : ',' .join (search_content_types ) if search_content_types else search_content_types ,
140174 })
141175 )
142176
0 commit comments