1010import redis .commands .search
1111import redis .commands .search .aggregation as aggregations
1212import redis .commands .search .reducers as reducers
13- from redis import Redis
1413from redis .commands .json .path import Path
1514from redis .commands .search import Search
1615from redis .commands .search .field import GeoField , NumericField , TagField , TextField
1918from redis .commands .search .result import Result
2019from redis .commands .search .suggestion import Suggestion
2120
22- from .conftest import default_redismod_url , skip_ifmodversion_lt
23-
24- pytestmark = pytest .mark .onlynoncluster
25-
21+ from .conftest import skip_ifmodversion_lt
2622
2723WILL_PLAY_TEXT = os .path .abspath (
2824 os .path .join (os .path .dirname (__file__ ), "testdata" , "will_play_text.csv.bz2" )
3632def waitForIndex (env , idx , timeout = None ):
3733 delay = 0.1
3834 while True :
39- res = env .execute_command ("ft.info " , idx )
35+ res = env .execute_command ("FT.INFO " , idx )
4036 try :
4137 res .index ("indexing" )
4238 except ValueError :
@@ -52,13 +48,12 @@ def waitForIndex(env, idx, timeout=None):
5248 break
5349
5450
55- def getClient ():
51+ def getClient (client ):
5652 """
5753 Gets a client client attached to an index name which is ready to be
5854 created
5955 """
60- rc = Redis .from_url (default_redismod_url , decode_responses = True )
61- return rc
56+ return client
6257
6358
6459def createIndex (client , num_docs = 100 , definition = None ):
@@ -96,12 +91,6 @@ def createIndex(client, num_docs=100, definition=None):
9691 indexer .commit ()
9792
9893
99- # override the default module client, search requires both db=0, and text
100- @pytest .fixture
101- def modclient ():
102- return Redis .from_url (default_redismod_url , db = 0 , decode_responses = True )
103-
104-
10594@pytest .fixture
10695def client (modclient ):
10796 modclient .flushdb ()
@@ -234,6 +223,7 @@ def test_payloads(client):
234223
235224
236225@pytest .mark .redismod
226+ @pytest .mark .onlynoncluster
237227def test_scores (client ):
238228 client .ft ().create_index ((TextField ("txt" ),))
239229
@@ -356,14 +346,14 @@ def test_sort_by(client):
356346
357347@pytest .mark .redismod
358348@skip_ifmodversion_lt ("2.0.0" , "search" )
359- def test_drop_index ():
349+ def test_drop_index (client ):
360350 """
361351 Ensure the index gets dropped by data remains by default
362352 """
363353 for x in range (20 ):
364354 for keep_docs in [[True , {}], [False , {"name" : "haveit" }]]:
365355 idx = "HaveIt"
366- index = getClient ()
356+ index = getClient (client )
367357 index .hset ("index:haveit" , mapping = {"name" : "haveit" })
368358 idef = IndexDefinition (prefix = ["index:" ])
369359 index .ft (idx ).create_index ((TextField ("name" ),), definition = idef )
@@ -574,9 +564,9 @@ def test_summarize(client):
574564
575565@pytest .mark .redismod
576566@skip_ifmodversion_lt ("2.0.0" , "search" )
577- def test_alias ():
578- index1 = getClient ()
579- index2 = getClient ()
567+ def test_alias (client ):
568+ index1 = getClient (client )
569+ index2 = getClient (client )
580570
581571 def1 = IndexDefinition (prefix = ["index1:" ])
582572 def2 = IndexDefinition (prefix = ["index2:" ])
@@ -594,7 +584,7 @@ def test_alias():
594584
595585 # create alias and check for results
596586 ftindex1 .aliasadd ("spaceballs" )
597- alias_client = getClient ().ft ("spaceballs" )
587+ alias_client = getClient (client ).ft ("spaceballs" )
598588 res = alias_client .search ("*" ).docs [0 ]
599589 assert "index1:lonestar" == res .id
600590
@@ -604,7 +594,7 @@ def test_alias():
604594
605595 # update alias and ensure new results
606596 ftindex2 .aliasupdate ("spaceballs" )
607- alias_client2 = getClient ().ft ("spaceballs" )
597+ alias_client2 = getClient (client ).ft ("spaceballs" )
608598
609599 res = alias_client2 .search ("*" ).docs [0 ]
610600 assert "index2:yogurt" == res .id
@@ -615,21 +605,21 @@ def test_alias():
615605
616606
617607@pytest .mark .redismod
618- def test_alias_basic ():
608+ def test_alias_basic (client ):
619609 # Creating a client with one index
620- getClient ().flushdb ()
621- index1 = getClient ().ft ("testAlias" )
610+ getClient (client ).flushdb ()
611+ index1 = getClient (client ).ft ("testAlias" )
622612
623613 index1 .create_index ((TextField ("txt" ),))
624614 index1 .add_document ("doc1" , txt = "text goes here" )
625615
626- index2 = getClient ().ft ("testAlias2" )
616+ index2 = getClient (client ).ft ("testAlias2" )
627617 index2 .create_index ((TextField ("txt" ),))
628618 index2 .add_document ("doc2" , txt = "text goes here" )
629619
630620 # add the actual alias and check
631621 index1 .aliasadd ("myalias" )
632- alias_client = getClient ().ft ("myalias" )
622+ alias_client = getClient (client ).ft ("myalias" )
633623 res = sorted (alias_client .search ("*" ).docs , key = lambda x : x .id )
634624 assert "doc1" == res [0 ].id
635625
@@ -639,7 +629,7 @@ def test_alias_basic():
639629
640630 # update the alias and ensure we get doc2
641631 index2 .aliasupdate ("myalias" )
642- alias_client2 = getClient ().ft ("myalias" )
632+ alias_client2 = getClient (client ).ft ("myalias" )
643633 res = sorted (alias_client2 .search ("*" ).docs , key = lambda x : x .id )
644634 assert "doc1" == res [0 ].id
645635
@@ -790,6 +780,7 @@ def test_phonetic_matcher(client):
790780
791781
792782@pytest .mark .redismod
783+ @pytest .mark .onlynoncluster
793784def test_scorer (client ):
794785 client .ft ().create_index ((TextField ("description" ),))
795786
@@ -842,6 +833,7 @@ def test_get(client):
842833
843834
844835@pytest .mark .redismod
836+ @pytest .mark .onlynoncluster
845837@skip_ifmodversion_lt ("2.2.0" , "search" )
846838def test_config (client ):
847839 assert client .ft ().config_set ("TIMEOUT" , "100" )
@@ -854,6 +846,7 @@ def test_config(client):
854846
855847
856848@pytest .mark .redismod
849+ @pytest .mark .onlynoncluster
857850def test_aggregations_groupby (client ):
858851 # Creating the index definition and schema
859852 client .ft ().create_index (
@@ -1085,8 +1078,8 @@ def test_aggregations_apply(client):
10851078 CreatedDateTimeUTC = "@CreatedDateTimeUTC * 10"
10861079 )
10871080 res = client .ft ().aggregate (req )
1088- assert res .rows [0 ] == [ "CreatedDateTimeUTC" , "6373878785249699840" ]
1089- assert res . rows [ 1 ] == [ "CreatedDateTimeUTC " , "6373878758592700416" ]
1081+ res_set = set ([ res .rows [0 ][ 1 ], res . rows [ 1 ][ 1 ]])
1082+ assert res_set == set ([ "6373878785249699840 " , "6373878758592700416" ])
10901083
10911084
10921085@pytest .mark .redismod
@@ -1158,6 +1151,7 @@ def test_index_definition(client):
11581151
11591152
11601153@pytest .mark .redismod
1154+ @pytest .mark .onlynoncluster
11611155def testExpire (client ):
11621156 client .ft ().create_index ((TextField ("txt" , sortable = True ),), temporary = 4 )
11631157 ttl = client .execute_command ("ft.debug" , "TTL" , "idx" )
@@ -1477,6 +1471,7 @@ def test_json_with_jsonpath(client):
14771471
14781472
14791473@pytest .mark .redismod
1474+ @pytest .mark .onlynoncluster
14801475def test_profile (client ):
14811476 client .ft ().create_index ((TextField ("t" ),))
14821477 client .ft ().client .hset ("1" , "t" , "hello" )
@@ -1505,6 +1500,7 @@ def test_profile(client):
15051500
15061501
15071502@pytest .mark .redismod
1503+ @pytest .mark .onlynoncluster
15081504def test_profile_limited (client ):
15091505 client .ft ().create_index ((TextField ("t" ),))
15101506 client .ft ().client .hset ("1" , "t" , "hello" )
0 commit comments