Skip to content

Commit

Permalink
Mock fix
Browse files Browse the repository at this point in the history
  • Loading branch information
igorski-r7 committed Nov 19, 2024
1 parent 7a3c34c commit 6abf2d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
19 changes: 11 additions & 8 deletions plugins/redis/unit_test/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@
from parameterized import parameterized
import redis

@patch('redis.StrictRedis', side_effect=Util.mock_redis)
# @patch("redis.StrictRedis", return_value=Util.mock_redis())
class TestForward(TestCase):
@classmethod
def setUpClass(cls) -> None:
cls.action = Util.default_connector(Delete())
def setUp(self) -> None:
self.action = None
@patch("redis.StrictRedis", return_value=Util.mock_redis())
def mocked_connector(mocked_redis: MagicMock) -> None:
self.action = Util.default_connector(Delete())
mocked_connector()

def test_delete(self, _mock_request):
def test_delete(self):
input_param = Util.load_json("inputs/delete.json.exp")
actual = self.action.run(input_param)
validate(input_param, DeleteInput.schema)
expect = Util.load_json("expected/delete_exp.json.exp")
actual = self.action.run(input_param)
validate(input_param, self.action.input.schema)
self.assertEqual(expect, actual)
validate(actual, DeleteOutput.schema)
validate(actual, self.action.output.schema)

5 changes: 3 additions & 2 deletions plugins/redis/unit_test/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ def __init__(self):
pass

@staticmethod
def delete(self):
def delete(key_name: str):
return 10

@staticmethod
def get(self, params: str):
def get(params: str):
if params == "test":
return True

return MockResponse()



Expand Down

0 comments on commit 6abf2d9

Please sign in to comment.