##// 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 167 class InvalidationContext(object):
168 168 def __repr__(self):
169 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 172 def __init__(self, compute_func, repo_name, cache_type,
173 173 raise_exception=False):
@@ -432,7 +432,13 b' def test_get_repo_by_id(test, expected):'
432 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 442 from beaker.cache import cache_region
437 443 from rhodecode.lib import caches
438 444 from rhodecode.model.db import CacheKey
@@ -442,7 +448,7 b' def test_invalidation_context(pylonsapp)'
442 448 return 'result'
443 449
444 450 invalidator_context = CacheKey.repo_context_cache(
445 _dummy_func, 'test_repo_1', 'repo')
451 _dummy_func, test_repo_name, 'repo')
446 452
447 453 with invalidator_context as context:
448 454 invalidated = context.invalidate()
@@ -452,6 +458,8 b' def test_invalidation_context(pylonsapp)'
452 458 assert 'result' == result
453 459 assert isinstance(context, caches.FreshRegionCache)
454 460
461 assert 'InvalidationContext' in repr(invalidator_context)
462
455 463 with invalidator_context as context:
456 464 context.invalidate()
457 465 result = context.compute()
General Comments 0
You need to be logged in to leave comments. Login now