Skip to content
Open
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
8 changes: 3 additions & 5 deletions src/alga/cli_adhoc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from typing import Annotated

from rich import print
from rich import print_json
from typer import Argument, Typer

from alga import client
Expand All @@ -14,7 +14,5 @@
def adhoc(path: str, data: Annotated[str | None, Argument()] = None) -> None:
"""Send raw request to the TV"""

if data:
print(client.request(path, json.loads(data)))
else:
print(client.request(path))
data_str = json.loads(data) if data else None
print_json(data=client.request(path, data_str))
6 changes: 3 additions & 3 deletions tests/test_cli_adhoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def test_without_data(faker: Faker, mock_request: MagicMock) -> None:

result = runner.invoke(app, ["adhoc", path])

mock_request.assert_called_once_with(path)
mock_request.assert_called_once_with(path, None)
assert result.exit_code == 0
assert result.stdout == f"{return_value}\n"
assert result.stdout == f'"{return_value}"\n'


def test_with_data(faker: Faker, mock_request: MagicMock) -> None:
Expand All @@ -32,4 +32,4 @@ def test_with_data(faker: Faker, mock_request: MagicMock) -> None:

mock_request.assert_called_once_with(path, data)
assert result.exit_code == 0
assert result.stdout == f"{return_value}\n"
assert result.stdout == f'"{return_value}"\n'
Loading