3838
3939class SearchCollectionTestSuite :
4040 TEST_MANIFEST = [
41- 'test_cluster_query_collections' ,
4241 'test_scope_query_collections' ,
4342 'test_scope_search_fields' ,
4443 'test_scope_search_highlight' ,
4544 ]
4645
46+ @pytest .mark .parametrize ('query_op' , ['search_query' , 'search' ])
4747 @pytest .mark .asyncio
48- async def test_cluster_query_collections (self , cb_env ):
48+ async def test_scope_query_collections (self , cb_env , query_op ):
4949 q = search .TermQuery ('auto' )
50- res = cb_env .cluster .search_query (cb_env .TEST_COLLECTION_INDEX_NAME ,
51- q ,
52- SearchOptions (limit = 10 ,
53- scope_name = cb_env .scope .name ,
54- collections = [cb_env .collection .name ]))
50+ operation = getattr (cb_env .scope , query_op )
51+ res = operation (cb_env .TEST_COLLECTION_INDEX_NAME ,
52+ q ,
53+ SearchOptions (limit = 10 , collections = [cb_env .collection .name ]))
5554 rows = await cb_env .assert_rows (res , 2 , return_rows = True )
5655
5756 collections = list (map (lambda r : r .fields ['_$c' ], rows ))
5857 assert all ([c for c in collections if c == cb_env .collection .name ]) is True
5958
60- @pytest .mark .asyncio
61- async def test_scope_query_collections (self , cb_env ):
62- q = search .TermQuery ('auto' )
63- res = cb_env .scope .search_query (cb_env .TEST_COLLECTION_INDEX_NAME ,
64- q ,
65- SearchOptions (limit = 10 , collections = [cb_env .collection .name ]))
66- rows = await cb_env .assert_rows (res , 2 , return_rows = True )
67-
68- collections = list (map (lambda r : r .fields ['_$c' ], rows ))
69- assert all ([c for c in collections if c == cb_env .collection .name ]) is True
70-
71- res = cb_env .scope .search_query (cb_env .TEST_COLLECTION_INDEX_NAME , q , SearchOptions (limit = 10 ))
59+ res = operation (cb_env .TEST_COLLECTION_INDEX_NAME , q , SearchOptions (limit = 10 ))
7260 rows = await cb_env .assert_rows (res , 2 , return_rows = True )
7361
7462 collections = list (map (lambda r : r .fields ['_$c' ], rows ))
7563 assert all ([c for c in collections if c in [cb_env .collection .name , cb_env .OTHER_COLLECTION ]]) is True
7664
65+ @pytest .mark .parametrize ('query_op' , ['search_query' , 'search' ])
7766 @pytest .mark .asyncio
78- async def test_scope_search_fields (self , cb_env ):
67+ async def test_scope_search_fields (self , cb_env , query_op ):
7968 test_fields = ['make' , 'model' ]
69+ operation = getattr (cb_env .scope , query_op )
8070 q = search .TermQuery ('auto' )
8171 # verify fields works w/in kwargs
82- res = cb_env . scope . search_query (cb_env .TEST_COLLECTION_INDEX_NAME ,
83- q ,
84- SearchOptions (limit = 10 ),
85- fields = test_fields ,
86- collections = [cb_env .collection .name ])
72+ res = operation (cb_env .TEST_COLLECTION_INDEX_NAME ,
73+ q ,
74+ SearchOptions (limit = 10 ),
75+ fields = test_fields ,
76+ collections = [cb_env .collection .name ])
8777
8878 fields_with_col = copy (test_fields )
8979 fields_with_col .append ('_$c' )
@@ -97,11 +87,11 @@ async def test_scope_search_fields(self, cb_env):
9787 assert all ([c for c in collections if c == cb_env .collection .name ]) is True
9888
9989 # verify fields works w/in options
100- res = cb_env . scope . search_query (cb_env .TEST_COLLECTION_INDEX_NAME ,
101- q ,
102- SearchOptions (limit = 10 ,
103- fields = test_fields ,
104- collections = [cb_env .collection .name ]))
90+ res = operation (cb_env .TEST_COLLECTION_INDEX_NAME ,
91+ q ,
92+ SearchOptions (limit = 10 ,
93+ fields = test_fields ,
94+ collections = [cb_env .collection .name ]))
10595
10696 rows = await cb_env .assert_rows (res , 1 , return_rows = True )
10797 first_entry = rows [0 ]
@@ -112,14 +102,15 @@ async def test_scope_search_fields(self, cb_env):
112102 collections = list (map (lambda r : r .fields ['_$c' ], rows ))
113103 assert all ([c for c in collections if c == cb_env .collection .name ]) is True
114104
105+ @pytest .mark .parametrize ('query_op' , ['search_query' , 'search' ])
115106 @pytest .mark .asyncio
116- async def test_scope_search_highlight (self , cb_env ):
117-
107+ async def test_scope_search_highlight (self , cb_env , query_op ):
118108 q = search .TermQuery ('auto' )
109+ operation = getattr (cb_env .scope , query_op )
119110 # check w/in options
120- res = cb_env . scope . search_query (cb_env .TEST_COLLECTION_INDEX_NAME ,
121- q ,
122- SearchOptions (limit = 10 , highlight_style = HighlightStyle .Html ))
111+ res = operation (cb_env .TEST_COLLECTION_INDEX_NAME ,
112+ q ,
113+ SearchOptions (limit = 10 , highlight_style = HighlightStyle .Html ))
123114 rows = await cb_env .assert_rows (res , 1 , return_rows = True )
124115 locations = rows [0 ].locations
125116 fragments = rows [0 ].fragments
@@ -130,8 +121,11 @@ async def test_scope_search_highlight(self, cb_env):
130121 assert all ([c for c in collections if c == cb_env .collection .name ]) is True
131122
132123 # check w/in kwargs
133- res = cb_env .scope .search_query (cb_env .TEST_COLLECTION_INDEX_NAME , q , SearchOptions (
134- limit = 10 ), highlight_style = HighlightStyle .Html , collections = [cb_env .collection .name ])
124+ res = operation (cb_env .TEST_COLLECTION_INDEX_NAME ,
125+ q ,
126+ SearchOptions (limit = 10 ),
127+ highlight_style = HighlightStyle .Html ,
128+ collections = [cb_env .collection .name ])
135129 rows = await cb_env .assert_rows (res , 1 , return_rows = True )
136130 locations = rows [0 ].locations
137131 fragments = rows [0 ].fragments
@@ -753,7 +747,7 @@ async def couchbase_test_environment(self, acb_base_env, test_manifest_validated
753747 pytest .fail (f'Test manifest not validated. Missing tests: { test_manifest_validated } .' )
754748
755749 acb_env = AsyncSearchTestEnvironment .from_environment (acb_base_env )
756- acb_env .enable_search_mgmt ()
750+ # acb_env.enable_search_mgmt()
757751 await acb_env .setup (request .param )
758752 yield acb_env
759753 await acb_env .teardown (request .param )
@@ -775,7 +769,7 @@ async def couchbase_test_environment(self, acb_base_env, test_manifest_validated
775769 pytest .fail (f'Test manifest not validated. Missing tests: { test_manifest_validated } .' )
776770
777771 acb_env = AsyncSearchTestEnvironment .from_environment (acb_base_env )
778- acb_env .enable_search_mgmt ()
772+ # acb_env.enable_search_mgmt()
779773 await acb_env .setup (request .param )
780774 yield acb_env
781775 await acb_env .teardown (request .param )
0 commit comments