blob: 684d0cfaa20c1f48ce42dd4edd8438105d605832 [file] [log] [blame]
Wei-Yu Chenad55cb82022-02-15 20:07:01 +08001# SPDX-FileCopyrightText: 2020 The Magma Authors.
2# SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
3#
4# SPDX-License-Identifier: BSD-3-Clause
Wei-Yu Chen49950b92021-11-08 19:19:18 +08005
Wei-Yu Chen49950b92021-11-08 19:19:18 +08006from redis.exceptions import RedisError
7
8# For non-failure cases, just use the fakeredis module
9
10
11class MockUnavailableRedis(object):
12 """
13 MockUnavailableRedis implements a mock Redis Server that always raises
14 a connection exception
15 """
16
17 def __init__(self, host, port):
18 self.host = host
19 self.port = port
20
21 def lock(self, key):
22 raise RedisError("mock redis error")
23
24 def keys(self, pattern=".*"):
25 """ Mock keys with regex pattern matching."""
26 raise RedisError("mock redis error")