1919
2020TITLES_CSV = os .path .abspath (os .path .dirname (__file__ )) + '/titles.csv'
2121
22+ v = 0
23+
2224def waitForIndex (env , idx , timeout = None ):
2325 delay = 0.1
2426 while True :
@@ -37,19 +39,11 @@ def waitForIndex(env, idx, timeout=None):
3739 if timeout <= 0 :
3840 break
3941
40- def check_version_2 (env ):
41- try :
42- # Indexing the hash
43- env .execute_command ('FT.ADDHASH foo bar 1' )
44- except redis .ResponseError as e :
45- # Support for FT.ADDHASH was removed in RediSearch 2.0
46- if str (e ).startswith ('unknown command `FT.ADDHASH`' ):
47- return True
48- return False
49-
50- def check_edge (env ):
51- v = env .execute_command ('MODULE LIST' )[0 ][3 ]
52- if v is "999999" :
42+ def check_version (env , version ):
43+ global v
44+ if v == 0 :
45+ v = env .execute_command ('MODULE LIST' )[0 ][3 ]
46+ if int (v ) >= version :
5347 return True
5448 return False
5549
@@ -209,7 +203,7 @@ def testAddHash(self):
209203 conn = self .redis ()
210204
211205 with conn as r :
212- if check_version_2 ( r ):
206+ if check_version ( r , 20000 ):
213207 return
214208 # Creating a client with a given index name
215209 client = Client ('idx' , port = conn .port )
@@ -236,7 +230,7 @@ def testPayloads(self):
236230 conn = self .redis ()
237231
238232 with conn as r :
239- if not check_edge ( r ):
233+ if not check_version ( r , 20200 ):
240234 return
241235 # Creating a client with a given index name
242236 client = Client ('idx' , port = conn .port )
@@ -574,7 +568,7 @@ def testSummarize(self):
574568 def testAlias (self ):
575569 conn = self .redis ()
576570 with conn as r :
577- if check_version_2 ( r ):
571+ if check_version ( r , 20000 ):
578572
579573 index1 = Client ('testAlias' , port = conn .port )
580574 index1 .redis .flushdb ()
@@ -810,7 +804,7 @@ def testGet(self):
810804
811805 def testConfig (self ):
812806 client = self .getCleanClient ('idx' )
813- if not check_edge (client .redis ):
807+ if not check_version (client .redis , 20200 ):
814808 return
815809 self .assertTrue (client .config_set ('TIMEOUT' , '100' ))
816810 with self .assertRaises (redis .ResponseError ) as error :
@@ -893,7 +887,7 @@ def testIndexDefiniontion(self):
893887
894888 with conn as r :
895889 r .flushdb ()
896- if not check_version_2 ( r ):
890+ if not check_version ( r , 20000 ):
897891 return
898892 client = Client ('test' , port = conn .port )
899893
@@ -914,7 +908,7 @@ def testCreateClientDefiniontion(self):
914908
915909 with conn as r :
916910 r .flushdb ()
917- if not check_version_2 ( r ):
911+ if not check_version ( r , 20000 ):
918912 return
919913 client = Client ('test' , port = conn .port )
920914
0 commit comments