Skip to content

Commit

Permalink
fix test bug while adding param for ping
Browse files Browse the repository at this point in the history
  • Loading branch information
spyinx committed Dec 11, 2024
1 parent 4f02122 commit b838613
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,9 +865,9 @@ def test_object(self, r):
def test_ping(self, r):
assert r.ping()
assert r.ping(0)
assert r.ping("Valkey")
assert r.ping(" Valkey ")
assert r.ping("Valkey", test="a")
assert r.ping("valkey")
assert r.ping(" hello ")
assert r.ping("abc", test="a")

@pytest.mark.onlynoncluster
def test_quit(self, r):
Expand Down
7 changes: 5 additions & 2 deletions valkey/_parsers/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import datetime

from valkey.utils import str_if_bytes, safe_str
from valkey.utils import (
safe_str,
str_if_bytes,
)


def timestamp_to_datetime(response):
Expand Down Expand Up @@ -686,7 +689,7 @@ def parse_set_result(response, **options):

def parse_ping(response, **options):
response = str_if_bytes(response)
message = "PONG" if options.get("message") is None else options.get("message")
message = options.get("message", "PONG")
return response == safe_str(message)


Expand Down
4 changes: 3 additions & 1 deletion valkey/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,9 @@ def ping(self, message=None, **kwargs) -> ResponseT:
For more information see https://valkey.io/commands/ping
"""
args = ["PING", message] if message is not None else ["PING"]
return self.execute_command(*args, message=message, **kwargs)
if message is not None:
kwargs["message"] = message
return self.execute_command(*args, **kwargs)

def quit(self, **kwargs) -> ResponseT:
"""
Expand Down

0 comments on commit b838613

Please sign in to comment.