@@ -1207,6 +1207,20 @@ def test_get_search_result_with_invalid_argument(self):
12071207 err = cm .exception
12081208 self .assertEqual (str (err ), 'Invalid argument: foo' )
12091209
1210+ def test_get_search_result_with_both_q_and_query (self ):
1211+ """
1212+ Test get_search_result by passing in both a q and query parameter
1213+ """
1214+ with self .assertRaises (CloudantArgumentError ) as cm :
1215+ self .db .get_search_result ('searchddoc001' , 'searchindex001' ,
1216+ query = 'julia*' , q = 'julia*' )
1217+ err = cm .exception
1218+ self .assertEqual (
1219+ str (err ),
1220+ 'A single query/q parameter is required. '
1221+ 'Found: {\' q\' : \' julia*\' , \' query\' : \' julia*\' }'
1222+ )
1223+
12101224 def test_get_search_result_with_invalid_value_types (self ):
12111225 """
12121226 Test get_search_result by passing in invalid value types for
@@ -1252,8 +1266,8 @@ def test_get_search_result_without_query(self):
12521266 err = cm .exception
12531267 self .assertEqual (
12541268 str (err ),
1255- 'No query parameter found. Please add a query parameter '
1256- 'containing Lucene syntax and retry. '
1269+ 'A single query/q parameter is required. '
1270+ 'Found: { \' limit \' : 10, \' include_docs \' : True} '
12571271 )
12581272
12591273 def test_get_search_result_with_invalid_query_type (self ):
@@ -1271,7 +1285,7 @@ def test_get_search_result_with_invalid_query_type(self):
12711285
12721286 def test_get_search_result_executes_search_query (self ):
12731287 """
1274- Test get_search_result executes a search query
1288+ Test get_search_result executes a search with query parameter.
12751289 """
12761290 self .create_search_index ()
12771291 self .populate_db_with_documents (100 )
@@ -1313,6 +1327,28 @@ def test_get_search_result_executes_search_query(self):
13131327 'id' : 'julia004' , 'order' : ['julia004' , 1 ]}], 'total_rows' : 100 }
13141328 )
13151329
1330+ def test_get_search_result_executes_search_q (self ):
1331+ """
1332+ Test get_search_result executes a search query with q parameter.
1333+ """
1334+ self .create_search_index ()
1335+ self .populate_db_with_documents (100 )
1336+ resp = self .db .get_search_result (
1337+ 'searchddoc001' ,
1338+ 'searchindex001' ,
1339+ query = 'julia*' ,
1340+ sort = '_id<string>' ,
1341+ limit = 1
1342+ )
1343+ self .assertEqual (len (resp ['rows' ]), 1 )
1344+ self .assertTrue (resp ['bookmark' ])
1345+ resp .pop ('bookmark' )
1346+ self .assertEqual (
1347+ resp ,
1348+ {'rows' : [{'fields' : {'name' : 'julia' }, 'id' : 'julia000' ,
1349+ 'order' : ['julia000' , 0 ]}], 'total_rows' : 100 }
1350+ )
1351+
13161352 def test_get_search_result_executes_search_query_with_group_option (self ):
13171353 """
13181354 Test get_search_result executes a search query with grouping parameters.
0 commit comments