88from cache_helper import settings
99from cache_helper .decorators import cached
1010from cache_helper .interfaces import CacheHelperCacheable
11- from cache_helper .utils import get_function_type , get_final_cache_key , get_function_cache_key
11+ from cache_helper .utils import get_function_type , get_hashed_cache_key , get_function_cache_key
1212from cache_helper .exceptions import CacheKeyCreationError , CacheHelperFunctionError
1313
1414
@@ -36,7 +36,6 @@ def fun_math(self, a, b):
3636 def take_then_give_back (self , a ):
3737 return a
3838
39- @cached (60 * 60 )
4039 def instance_method (self ):
4140 return self .name
4241
@@ -142,7 +141,7 @@ def assertExpectedKeyInCache(self, key):
142141 """
143142 Tests given key is in cache, making sure to get the hashed version of key first
144143 """
145- finalized_key = get_final_cache_key (key )
144+ finalized_key = get_hashed_cache_key (key )
146145 self .assertTrue (finalized_key in cache )
147146
148147
@@ -202,11 +201,11 @@ def tearDown(self):
202201
203202 def test_unusual_character_key_creation (self ):
204203 return_string ('āęìøü' )
205- expected_key_unusual_chars = get_function_cache_key ('tests.return_string ' , 'function ' , ('āęìøü' ,), {})
204+ expected_key_unusual_chars = get_function_cache_key ('function ' , 'tests.return_string ' , ('āęìøü' ,), {})
206205 self .assertExpectedKeyInCache (expected_key_unusual_chars )
207206
208207 return_string ('aeiou' )
209- expected_key = get_function_cache_key ('tests.return_string ' , 'function ' , ('aeiou' ,), {})
208+ expected_key = get_function_cache_key ('function ' , 'tests.return_string ' , ('aeiou' ,), {})
210209 self .assertExpectedKeyInCache (expected_key )
211210
212211 self .assertNotEqual (expected_key_unusual_chars , expected_key )
@@ -216,13 +215,13 @@ def test_same_method_name_different_class(self):
216215 Two different classes with the same method name should have different cache keys
217216 """
218217 self .apple .take_then_give_back (self .cherry )
219- apple_take_give_back_cherry_key = get_function_cache_key (
220- 'tests.Fruit.take_then_give_back' , 'method' , (self .apple , self .cherry ), {})
218+ apple_take_give_back_cherry_key = get_function_cache_key ('method' , 'tests.Fruit.take_then_give_back' ,
219+ (self .apple , self .cherry ), {})
221220 self .assertExpectedKeyInCache (apple_take_give_back_cherry_key )
222221
223222 self .celery .take_then_give_back (self .cherry )
224- celery_take_give_back_cherry_key = get_function_cache_key (
225- 'tests.Vegetable.take_then_give_back' , 'method' , (self .celery , self .cherry ), {})
223+ celery_take_give_back_cherry_key = get_function_cache_key ('method' , 'tests.Vegetable.take_then_give_back' ,
224+ (self .celery , self .cherry ), {})
226225 self .assertExpectedKeyInCache (celery_take_give_back_cherry_key )
227226
228227 self .assertNotEqual (apple_take_give_back_cherry_key , celery_take_give_back_cherry_key )
@@ -232,13 +231,13 @@ def test_same_class_method_name_different_class(self):
232231 Two different classes with the same class method name should have different cache keys
233232 """
234233 self .apple .add_sweet_letter (self .cherry )
235- apple_add_sweet_cherry_key = get_function_cache_key (
236- 'tests.Fruit.add_sweet_letter' , 'class_method' , (self .apple , self .cherry ), {})
234+ apple_add_sweet_cherry_key = get_function_cache_key ('class_method' , 'tests.Fruit.add_sweet_letter' ,
235+ (self .apple , self .cherry ), {})
237236 self .assertExpectedKeyInCache (apple_add_sweet_cherry_key )
238237
239238 self .celery .add_sweet_letter (self .cherry )
240- celery_add_sweet_cherry_key = get_function_cache_key (
241- 'tests.Vegetable.add_sweet_letter' , 'class_method' , (self .celery , self .cherry ), {})
239+ celery_add_sweet_cherry_key = get_function_cache_key ('class_method' , 'tests.Vegetable.add_sweet_letter' ,
240+ (self .celery , self .cherry ), {})
242241 self .assertExpectedKeyInCache (celery_add_sweet_cherry_key )
243242
244243 self .assertNotEqual (apple_add_sweet_cherry_key , celery_add_sweet_cherry_key )
@@ -248,11 +247,12 @@ def test_same_static_method_name_different_class_instance_reference(self):
248247 Two different classes with the same static method name should have different cache keys
249248 """
250249 self .apple .static_method (self .cherry )
251- apple_static_method_key = get_function_cache_key ('tests.Fruit.static_method' , 'function ' , (self .cherry ,), {})
250+ apple_static_method_key = get_function_cache_key ('function' , ' tests.Fruit.static_method' , (self .cherry ,), {})
252251 self .assertExpectedKeyInCache (apple_static_method_key )
253252
254253 self .celery .static_method (self .cherry )
255- celery_static_method_key = get_function_cache_key ('tests.Vegetable.static_method' , 'function' , (self .cherry ,), {})
254+ celery_static_method_key = get_function_cache_key ('function' , 'tests.Vegetable.static_method' , (self .cherry ,),
255+ {})
256256 self .assertExpectedKeyInCache (celery_static_method_key )
257257
258258 self .assertNotEqual (apple_static_method_key , celery_static_method_key )
@@ -262,25 +262,24 @@ def test_same_static_method_name_different_class_class_reference(self):
262262 Two different classes with the same static method name should have different cache keys
263263 """
264264 Fruit .static_method (self .cherry )
265- fruit_static_method_key = get_function_cache_key ('tests.Fruit.static_method' , 'function ' , (self .cherry ,), {})
265+ fruit_static_method_key = get_function_cache_key ('function' , ' tests.Fruit.static_method' , (self .cherry ,), {})
266266 self .assertExpectedKeyInCache (fruit_static_method_key )
267267
268268 Vegetable .static_method (self .cherry )
269- vegetable_static_method_key = get_function_cache_key (
270- 'tests.Vegetable.static_method' , 'function' , (self .cherry ,), {})
269+ vegetable_static_method_key = get_function_cache_key ('function' , 'tests.Vegetable.static_method' ,
270+ (self .cherry ,), {})
271271 self .assertExpectedKeyInCache (vegetable_static_method_key )
272272
273273 self .assertNotEqual (fruit_static_method_key , vegetable_static_method_key )
274274
275275 def test_same_function_name_from_module_level (self ):
276276 """Two different functions with same name should have different cache keys"""
277277 Vegetable .foo (1 , 2 )
278- vegetable_static_method_key = get_function_cache_key (
279- 'tests.Vegetable.foo' , 'function' , (1 , 2 ), {})
278+ vegetable_static_method_key = get_function_cache_key ('function' , 'tests.Vegetable.foo' , (1 , 2 ), {})
280279 self .assertExpectedKeyInCache (vegetable_static_method_key )
281280
282281 foo (1 , 2 )
283- module_function_key = get_function_cache_key ('tests.foo ' , 'function ' , (1 , 2 ), {})
282+ module_function_key = get_function_cache_key ('function ' , 'tests.foo ' , (1 , 2 ), {})
284283 self .assertExpectedKeyInCache (module_function_key )
285284
286285 self .assertNotEqual (vegetable_static_method_key , module_function_key )
0 commit comments