Skip to content
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

Fix parsing of INFO response #3264

Merged
merged 1 commit into from
Jun 5, 2024
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
2 changes: 1 addition & 1 deletion redis/_parsers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def parse_info(response):
response = str_if_bytes(response)

def get_value(value):
if "," not in value or "=" not in value:
if "," not in value and "=" not in value:
try:
if "." in value:
return float(value)
Expand Down
35 changes: 35 additions & 0 deletions tests/test_parsers/test_helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from redis._parsers.helpers import parse_info


def test_parse_info():
info_output = """
# Modules
module:name=search,ver=999999,api=1,filters=0,usedby=[],using=[ReJSON],options=[handle-io-errors]
# search_fields_statistics
search_fields_text:Text=3
search_fields_tag:Tag=2,Sortable=1
# search_version
search_version:99.99.99
search_redis_version:7.2.2 - oss
# search_runtime_configurations
search_query_timeout_ms:500
"""
info = parse_info(info_output)

assert isinstance(info["modules"], list)
assert isinstance(info["modules"][0], dict)
assert info["modules"][0]["name"] == "search"

assert isinstance(info["search_fields_text"], dict)
assert info["search_fields_text"]["Text"] == 3

assert isinstance(info["search_fields_tag"], dict)
assert info["search_fields_tag"]["Tag"] == 2
assert info["search_fields_tag"]["Sortable"] == 1

assert info["search_version"] == "99.99.99"
assert info["search_redis_version"] == "7.2.2 - oss"
assert info["search_query_timeout_ms"] == 500
Loading