Skip to content

Commit

Permalink
feat: pretty prometheus tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roma-frolov committed Dec 20, 2024
1 parent 2f6abd9 commit 4c26157
Show file tree
Hide file tree
Showing 24 changed files with 393 additions and 302 deletions.
2 changes: 1 addition & 1 deletion faststream/confluent/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def from_cmd(
if body is None:
body = EMPTY

if isinstance(body, Sequence) and not isinstance(body, str):
if isinstance(body, Sequence) and not isinstance(body, (str, bytes)):
if body:
body, extra_bodies = body[0], body[1:]
else:
Expand Down
2 changes: 1 addition & 1 deletion faststream/kafka/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def from_cmd(
if body is None:
body = EMPTY

if isinstance(body, Sequence) and not isinstance(body, str):
if isinstance(body, Sequence) and not isinstance(body, (str, bytes)):
if body:
body, extra_bodies = body[0], body[1:]
else:
Expand Down
2 changes: 1 addition & 1 deletion faststream/redis/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def from_cmd(
if body is None:
body = EMPTY

if isinstance(body, Sequence) and not isinstance(body, str):
if isinstance(body, Sequence) and not isinstance(body, (str, bytes)):
if body:
body, extra_bodies = body[0], body[1:]
else:
Expand Down
2 changes: 1 addition & 1 deletion faststream/response/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(

@property
def batch_bodies(self) -> tuple["Any", ...]:
if self.body:
if self.body or isinstance(self.body, (str, bytes)):
return (self.body,)
return ()

Expand Down
2 changes: 2 additions & 0 deletions tests/brokers/confluent/test_publish_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def test_kafka_response_class():
pytest.param(None, (), id="None Response"),
pytest.param((), (), id="Empty Sequence"),
pytest.param("123", ("123",), id="String Response"),
pytest.param("", ("",), id="Empty String Response"),
pytest.param(b"", (b"",), id="Empty Bytes Response"),
pytest.param([1, 2, 3], (1, 2, 3), id="Sequence Data"),
pytest.param([0, 1, 2], (0, 1, 2), id="Sequence Data with False first element"),
),
Expand Down
2 changes: 2 additions & 0 deletions tests/brokers/kafka/test_publish_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def test_kafka_response_class():
pytest.param(None, (), id="None Response"),
pytest.param((), (), id="Empty Sequence"),
pytest.param("123", ("123",), id="String Response"),
pytest.param("", ("",), id="Empty String Response"),
pytest.param(b"", (b"",), id="Empty Bytes Response"),
pytest.param([1, 2, 3], (1, 2, 3), id="Sequence Data"),
pytest.param([0, 1, 2], (0, 1, 2), id="Sequence Data with False first element"),
),
Expand Down
2 changes: 2 additions & 0 deletions tests/brokers/redis/test_publish_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def test_kafka_response_class() -> None:
pytest.param(None, (), id="None Response"),
pytest.param((), (), id="Empty Sequence"),
pytest.param("123", ("123",), id="String Response"),
pytest.param("", ("",), id="Empty String Response"),
pytest.param(b"", (b"",), id="Empty Bytes Response"),
pytest.param([1, 2, 3], (1, 2, 3), id="Sequence Data"),
pytest.param([0, 1, 2], (0, 1, 2), id="Sequence Data with False first element"),
),
Expand Down
Loading

0 comments on commit 4c26157

Please sign in to comment.