Skip to content

Commit 0b3c4f6

Browse files
committed
test: add tests for misc treasury-address command
Add unit and integration tests for the treasury-address CLI command in tests/cli/test_misc.py. Tests cover mocked functionality and help command verification.
1 parent baaf2f2 commit 0b3c4f6

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/cli/test_misc.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from unittest.mock import Mock, patch
2+
3+
import pytest
4+
from typer.testing import CliRunner
5+
6+
from torusdk.cli.misc import misc_app
7+
8+
9+
class TestMiscCommands:
10+
def test_treasury_address_command(self):
11+
"""Test the treasury-address command returns expected address format."""
12+
runner = CliRunner()
13+
14+
# Mock the client and its method
15+
with patch("torusdk.cli.misc.make_custom_context") as mock_context:
16+
mock_client = Mock()
17+
mock_client.get_dao_treasury_address.return_value = (
18+
"5D4x123abc...treasury"
19+
)
20+
21+
mock_ctx = Mock()
22+
mock_ctx.com_client.return_value = mock_client
23+
mock_ctx.progress_status.return_value.__enter__ = Mock()
24+
mock_ctx.progress_status.return_value.__exit__ = Mock()
25+
mock_ctx.output = Mock()
26+
27+
mock_context.return_value = mock_ctx
28+
29+
result = runner.invoke(misc_app, ["treasury-address"])
30+
31+
assert result.exit_code == 0
32+
mock_client.get_dao_treasury_address.assert_called_once()
33+
mock_ctx.output.assert_called_once_with("5D4x123abc...treasury")
34+
35+
def test_treasury_address_command_integration(self):
36+
"""Integration test that verifies command structure without mocking client."""
37+
runner = CliRunner()
38+
39+
# This will fail due to missing network connection, but we can verify
40+
# the command is properly registered and the structure is correct
41+
result = runner.invoke(misc_app, ["treasury-address", "--help"])
42+
43+
assert result.exit_code == 0
44+
assert "treasury-address" in result.output

0 commit comments

Comments
 (0)