Skip to content

Commit b838613

Browse files
committed
fix test bug while adding param for ping
1 parent 4f02122 commit b838613

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

tests/test_commands.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,9 +865,9 @@ def test_object(self, r):
865865
def test_ping(self, r):
866866
assert r.ping()
867867
assert r.ping(0)
868-
assert r.ping("Valkey")
869-
assert r.ping(" Valkey ")
870-
assert r.ping("Valkey", test="a")
868+
assert r.ping("valkey")
869+
assert r.ping(" hello ")
870+
assert r.ping("abc", test="a")
871871

872872
@pytest.mark.onlynoncluster
873873
def test_quit(self, r):

valkey/_parsers/helpers.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import datetime
22

3-
from valkey.utils import str_if_bytes, safe_str
3+
from valkey.utils import (
4+
safe_str,
5+
str_if_bytes,
6+
)
47

58

69
def timestamp_to_datetime(response):
@@ -686,7 +689,7 @@ def parse_set_result(response, **options):
686689

687690
def parse_ping(response, **options):
688691
response = str_if_bytes(response)
689-
message = "PONG" if options.get("message") is None else options.get("message")
692+
message = options.get("message", "PONG")
690693
return response == safe_str(message)
691694

692695

valkey/commands/core.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,9 @@ def ping(self, message=None, **kwargs) -> ResponseT:
12101210
For more information see https://valkey.io/commands/ping
12111211
"""
12121212
args = ["PING", message] if message is not None else ["PING"]
1213-
return self.execute_command(*args, message=message, **kwargs)
1213+
if message is not None:
1214+
kwargs["message"] = message
1215+
return self.execute_command(*args, **kwargs)
12141216

12151217
def quit(self, **kwargs) -> ResponseT:
12161218
"""

0 commit comments

Comments
 (0)