"""Tests for the MYCO CLI tool.""" import json import sys from io import StringIO import pytest from src.cli import main class TestCLISimulate: def test_simulate_token_launch_text(self, capsys): code = main(["simulate", "token-launch", "--duration", "30"]) assert code == 0 out = capsys.readouterr().out assert "Final supply" in out def test_simulate_token_launch_json(self, capsys): code = main(["simulate", "token-launch", "--duration", "30", "--output", "json"]) assert code == 0 data = json.loads(capsys.readouterr().out) assert "supply" in data assert "reserve_value" in data def test_simulate_unknown_scenario(self): with pytest.raises(SystemExit) as exc_info: main(["simulate", "nonexistent"]) assert exc_info.value.code == 2 class TestCLIDCA: def test_compare_dca_text(self, capsys): code = main(["compare-dca", "--total", "5000", "--chunks", "5"]) assert code == 0 out = capsys.readouterr().out assert "fixed" in out assert "twap_aware" in out def test_compare_dca_json(self, capsys): code = main(["compare-dca", "--total", "5000", "--chunks", "5", "--output", "json"]) assert code == 0 data = json.loads(capsys.readouterr().out) assert "fixed" in data assert "twap_aware" in data class TestCLISignalRouting: def test_signal_routing_text(self, capsys): code = main(["signal-routing", "--trajectory", "volatile", "--steps", "20"]) assert code == 0 out = capsys.readouterr().out assert "flow_threshold" in out def test_signal_routing_json(self, capsys): code = main(["signal-routing", "--trajectory", "stable", "--steps", "10", "--output", "json"]) assert code == 0 data = json.loads(capsys.readouterr().out) assert "flow_threshold" in data assert len(data["times"]) == 10 class TestCLIStressTest: def test_stress_test(self, capsys): code = main(["stress-test", "--fractions", "0.02", "0.05"]) assert code == 0 out = capsys.readouterr().out assert "0.02" in out assert "0.05" in out class TestCLIHelp: def test_no_command_shows_help(self, capsys): code = main([]) assert code == 0