@@ -15,7 +15,7 @@ def test_open_index():
1515 if not os .path .exists (test_dir ):
1616 os .mkdir (test_dir )
1717 index = Index (os .path .join (test_dir , "index" ))
18- index .Set ("a" , "{}" )
18+ index .set ("a" , "{}" )
1919 del index
2020 # required for pypy to ensure deletion/destruction of the index object
2121 gc .collect ()
@@ -35,12 +35,12 @@ def test_some_indexing():
3535 os .mkdir (test_dir )
3636 index = Index (os .path .join (test_dir , "index" ))
3737 for i in range (0 , iterations ):
38- index .Set ("key-{}" .format (i ), "value-{}" .format (i ))
39- index .Flush ()
38+ index .set ("key-{}" .format (i ), "value-{}" .format (i ))
39+ index .flush ()
4040 for i in range (split , iterations ):
4141 assert "key-{}" .format (i ) in index
42- index .Delete ("key-{}" .format (i ))
43- index .Flush ()
42+ index .delete ("key-{}" .format (i ))
43+ index .flush ()
4444
4545 for i in range (0 , split ):
4646 assert "key-{}" .format (i ) in index
@@ -65,10 +65,10 @@ def test_bulk_add():
6565 for i in range (0 , chunk_size * iterations ):
6666 key_values .append (("key-{}" .format (i ), "value-{}" .format (i )))
6767 if i % chunk_size == 0 :
68- index .MSet (key_values )
68+ index .mset (key_values )
6969 key_values = []
70- index .MSet (key_values )
71- index .Flush ()
70+ index .mset (key_values )
71+ index .flush ()
7272
7373 for i in range (0 , 50 ):
7474 assert "key-{}" .format (random .randrange (0 ,
@@ -84,36 +84,36 @@ def test_get_fuzzy():
8484 if not os .path .exists (test_dir ):
8585 os .mkdir (test_dir )
8686 write_index = Index (os .path .join (test_dir , "index" ))
87- write_index .Set ("apple" , "{}" )
88- write_index .Set ("apples" , "{}" )
89- write_index .Set ("banana" , "{}" )
90- write_index .Set ("orange" , "{}" )
91- write_index .Set ("avocado" , "{}" )
92- write_index .Set ("peach" , "{}" )
93- write_index .Flush ()
87+ write_index .set ("apple" , "{}" )
88+ write_index .set ("apples" , "{}" )
89+ write_index .set ("banana" , "{}" )
90+ write_index .set ("orange" , "{}" )
91+ write_index .set ("avocado" , "{}" )
92+ write_index .set ("peach" , "{}" )
93+ write_index .flush ()
9494
9595 read_only_index = ReadOnlyIndex (os .path .join (test_dir , "index" ))
9696
9797 for index in [write_index , read_only_index ]:
98- matches = list (index .GetFuzzy ("appe" , 1 , 2 ))
98+ matches = list (index .get_fuzzy ("appe" , 1 , 2 ))
9999 assert len (matches ) == 1
100100 assert u'apple' == matches [0 ].matched_string
101101
102- matches = list (index .GetFuzzy ("appes" , 2 , 2 ))
102+ matches = list (index .get_fuzzy ("appes" , 2 , 2 ))
103103 assert len (matches ) == 2
104104 assert u'apple' == matches [0 ].matched_string
105105 assert u'apples' == matches [1 ].matched_string
106- matches = list (index .GetFuzzy ("apples" , 1 , 2 ))
106+ matches = list (index .get_fuzzy ("apples" , 1 , 2 ))
107107 assert len (matches ) == 2
108108 assert u'apple' == matches [0 ].matched_string
109109 assert u'apples' == matches [1 ].matched_string
110- matches = list (index .GetFuzzy ("atocao" , 2 , 1 ))
110+ matches = list (index .get_fuzzy ("atocao" , 2 , 1 ))
111111 assert len (matches ) == 1
112112 assert u'avocado' == matches [0 ].matched_string
113113
114- write_index .Delete ("avocado" )
115- write_index .Flush ()
116- matches = list (write_index .GetFuzzy ("atocao" , 2 , 1 ))
114+ write_index .delete ("avocado" )
115+ write_index .flush ()
116+ matches = list (write_index .get_fuzzy ("atocao" , 2 , 1 ))
117117 assert len (matches ) == 0
118118
119119 del write_index
@@ -129,43 +129,43 @@ def test_get_near():
129129 os .mkdir (test_dir )
130130 write_index = Index (os .path .join (test_dir , "index" ))
131131 # the following geohashes are created from openstreetmap coordinates and translated using a geohash encoder
132- write_index .Set (
132+ write_index .set (
133133 "u21xj502gs79" , "{'city' : 'Kobarid', 'country': 'si'}" )
134- write_index .Set (
134+ write_index .set (
135135 "u21xk2uxkhh2" , "{'city' : 'Trnovo ob soci', 'country': 'si'}" )
136- write_index .Set (
136+ write_index .set (
137137 "u21x75n34qrp" , "{'city' : 'Srpnecia', 'country': 'si'}" )
138- write_index .Set ("u21x6v1nx0c3" , "{'city' : 'Zaga', 'country': 'si'}" )
139- write_index .Set (
138+ write_index .set ("u21x6v1nx0c3" , "{'city' : 'Zaga', 'country': 'si'}" )
139+ write_index .set (
140140 "u21xs20w9ssu" , "{'city' : 'Cezsoca', 'country': 'si'}" )
141- write_index .Set (
141+ write_index .set (
142142 "u21x6yx5cqy6" , "{'city' : 'Log Cezsoski', 'country': 'si'}" )
143- write_index .Set ("u21xs7ses4s3" , "{'city' : 'Bovec', 'country': 'si'}" )
144- write_index .Flush ()
143+ write_index .set ("u21xs7ses4s3" , "{'city' : 'Bovec', 'country': 'si'}" )
144+ write_index .flush ()
145145
146146 read_only_index = ReadOnlyIndex (os .path .join (test_dir , "index" ))
147147
148148 for index in [write_index , read_only_index ]:
149149 # some coordinate nearby, greedy false, so it prefers as close as possible
150- matches = list (index .GetNear ("u21xjjhhymt7" , 4 ))
150+ matches = list (index .get_near ("u21xjjhhymt7" , 4 ))
151151 assert len (matches ) == 1
152152 assert u'u21xj502gs79' == matches [0 ].matched_string
153153 assert u"{'city' : 'Kobarid', 'country': 'si'}" == matches [0 ].value
154154
155155 # greedy match, still closest should be the 1st match
156- matches = list (index .GetNear ("u21xjjhhymt7" , 4 , True ))
156+ matches = list (index .get_near ("u21xjjhhymt7" , 4 , True ))
157157 assert len (matches ) == 7
158158 assert u'u21xj502gs79' == matches [0 ].matched_string
159159 assert u"{'city' : 'Kobarid', 'country': 'si'}" == matches [0 ].value
160160
161161 # closer match near Bovec and Cezsoca but closer to Cezsoca
162- matches = list (index .GetNear ("u21xs20w9ssu" , 5 ))
162+ matches = list (index .get_near ("u21xs20w9ssu" , 5 ))
163163 assert len (matches ) == 1
164164 assert u'u21xs20w9ssu' == matches [0 ].matched_string
165165 assert u"{'city' : 'Cezsoca', 'country': 'si'}" == matches [0 ].value
166166
167167 # greedy should return Bovec, but not the other locations due to the prefix
168- matches = list (index .GetNear ("u21xs20w9ssu" , 5 , True ))
168+ matches = list (index .get_near ("u21xs20w9ssu" , 5 , True ))
169169 assert len (matches ) == 2
170170 assert u'u21xs20w9ssu' == matches [0 ].matched_string
171171 assert u"{'city' : 'Cezsoca', 'country': 'si'}" == matches [0 ].value
0 commit comments