##// END OF EJS Templates
caches: make sure __repr__ of invalidaiton context always return strings....
marcink -
r293:3df2eb52 default
parent child Browse files
Show More
@@ -167,7 +167,7 b' class FreshRegionCache(ActiveRegionCache'
167 class InvalidationContext(object):
167 class InvalidationContext(object):
168 def __repr__(self):
168 def __repr__(self):
169 return '<InvalidationContext:{}[{}]>'.format(
169 return '<InvalidationContext:{}[{}]>'.format(
170 self.repo_name, self.cache_type)
170 safe_str(self.repo_name), safe_str(self.cache_type))
171
171
172 def __init__(self, compute_func, repo_name, cache_type,
172 def __init__(self, compute_func, repo_name, cache_type,
173 raise_exception=False):
173 raise_exception=False):
@@ -432,7 +432,13 b' def test_get_repo_by_id(test, expected):'
432 assert _test == expected
432 assert _test == expected
433
433
434
434
435 def test_invalidation_context(pylonsapp):
435 @pytest.mark.parametrize("test_repo_name, repo_type", [
436 ("test_repo_1", None),
437 ("repo_group/foobar", None),
438 ("test_non_asci_ąćę", None),
439 (u"test_non_asci_unicode_ąćę", None),
440 ])
441 def test_invalidation_context(pylonsapp, test_repo_name, repo_type):
436 from beaker.cache import cache_region
442 from beaker.cache import cache_region
437 from rhodecode.lib import caches
443 from rhodecode.lib import caches
438 from rhodecode.model.db import CacheKey
444 from rhodecode.model.db import CacheKey
@@ -442,7 +448,7 b' def test_invalidation_context(pylonsapp)'
442 return 'result'
448 return 'result'
443
449
444 invalidator_context = CacheKey.repo_context_cache(
450 invalidator_context = CacheKey.repo_context_cache(
445 _dummy_func, 'test_repo_1', 'repo')
451 _dummy_func, test_repo_name, 'repo')
446
452
447 with invalidator_context as context:
453 with invalidator_context as context:
448 invalidated = context.invalidate()
454 invalidated = context.invalidate()
@@ -452,6 +458,8 b' def test_invalidation_context(pylonsapp)'
452 assert 'result' == result
458 assert 'result' == result
453 assert isinstance(context, caches.FreshRegionCache)
459 assert isinstance(context, caches.FreshRegionCache)
454
460
461 assert 'InvalidationContext' in repr(invalidator_context)
462
455 with invalidator_context as context:
463 with invalidator_context as context:
456 context.invalidate()
464 context.invalidate()
457 result = context.compute()
465 result = context.compute()
General Comments 0
You need to be logged in to leave comments. Login now