def test_clears_cache_on_transaction_end(self, patch, db_session, users): funcs = {} # We need to capture the inline `clear_cache` function so we can # call it manually later def on_transaction_end_decorator(session): def on_transaction_end(func): funcs['clear_cache'] = func return on_transaction_end decorator = patch('h.services.user.util.db.on_transaction_end') decorator.side_effect = on_transaction_end_decorator jacqui, _, _ = users svc = UserService(default_authority='example.com', session=db_session) svc.fetch('acct:[email protected]') db_session.delete(jacqui) funcs['clear_cache']() user = svc.fetch('acct:[email protected]') assert user is None
def test_clears_cache_on_transaction_end(self, patch, db_session, users): funcs = {} # We need to capture the inline `clear_cache` function so we can # call it manually later def on_transaction_end_decorator(session): def on_transaction_end(func): funcs["clear_cache"] = func return on_transaction_end decorator = patch("h.services.user.on_transaction_end") decorator.side_effect = on_transaction_end_decorator jacqui, _, _, _ = users svc = UserService(default_authority="example.com", session=db_session) svc.fetch("acct:[email protected]") db_session.delete(jacqui) funcs["clear_cache"]() user = svc.fetch("acct:[email protected]") assert user is None
def test_clears_cache_on_transaction_end(self, patch, db_session, users): funcs = {} # We need to capture the inline `clear_cache` function so we can # call it manually later def on_transaction_end_decorator(session): # pylint:disable=unused-argument def on_transaction_end(func): funcs["clear_cache"] = func return on_transaction_end decorator = patch("h.services.user.on_transaction_end") decorator.side_effect = on_transaction_end_decorator jacqui, _, _, _ = users svc = UserService(default_authority="example.com", session=db_session) svc.fetch("acct:[email protected]") db_session.delete(jacqui) funcs["clear_cache"]() user = svc.fetch("acct:[email protected]") assert user is None