Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_check_redis_connected(mocker, redis_store, exception, error):
ping = mocker.patch.object(redis_store, "ping")
ping.side_effect = exception
errors = checks.check_redis_connected(redis_store)
assert len(errors) == 1
assert errors[0].id == error
def test_check_redis_connected_ping_check(mocker, redis_store):
ping = mocker.patch.object(redis_store, "ping")
ping.return_value = True
errors = checks.check_redis_connected(redis_store)
assert len(errors) == 0
ping.return_value = False
errors = checks.check_redis_connected(redis_store)
assert len(errors) == 1
assert errors[0].id == health.ERROR_REDIS_PING_FAILED