Skip to content

Supporting args with MODULE LOAD #1579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions redis/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3081,12 +3081,14 @@ def _geosearchgeneric(self, command, *args, **kwargs):
return self.execute_command(command, *pieces, **kwargs)

# MODULE COMMANDS
def module_load(self, path):
def module_load(self, path, *args):
"""
Loads the module from ``path``.
Raises ``ModuleError`` if a module is not found at ``path``.
"""
return self.execute_command('MODULE LOAD', path)
pieces = list(args)
pieces.insert(0, path)
return self.execute_command('MODULE LOAD', *pieces)

def module_unload(self, name):
"""
Expand Down
10 changes: 10 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3461,6 +3461,16 @@ def test_command_count(self, r):
assert isinstance(res, int)
assert res >= 100

@skip_if_server_version_lt('4.0.0')
def test_module(self, r):
with pytest.raises(redis.exceptions.ModuleError) as excinfo:
r.module_load('/some/fake/path')
assert "Error loading the extension." in str(excinfo.value)

with pytest.raises(redis.exceptions.ModuleError) as excinfo:
r.module_load('/some/fake/path', 'arg1', 'arg2', 'arg3', 'arg4')
assert "Error loading the extension." in str(excinfo.value)


class TestBinarySave:

Expand Down