@@ -81,6 +81,42 @@ def test_task_list_json_no_spinner(_mock_exp, _mock_api):
8181 json .loads (result .output .strip ()) # must not raise
8282
8383
84+ @patch ("transformerlab_cli.commands.task.api.get" , return_value = _mock_resp (SAMPLE_TASKS ))
85+ @patch ("transformerlab_cli.commands.task.require_current_experiment" , return_value = "exp1" )
86+ def test_task_list_no_subtype_hits_list_by_type (_mock_exp , mock_api_get ):
87+ """Without --subtype, list calls list_by_type_in_experiment."""
88+ result = runner .invoke (app , ["--format" , "json" , "task" , "list" ])
89+ assert result .exit_code == 0
90+ called_url = mock_api_get .call_args .args [0 ]
91+ assert "list_by_type_in_experiment" in called_url
92+ assert "type=REMOTE" in called_url
93+ assert "subtype=" not in called_url
94+
95+
96+ @patch ("transformerlab_cli.commands.task.api.get" , return_value = _mock_resp (SAMPLE_TASKS ))
97+ @patch ("transformerlab_cli.commands.task.require_current_experiment" , return_value = "exp1" )
98+ def test_task_list_with_subtype_hits_list_by_subtype (_mock_exp , mock_api_get ):
99+ """--subtype interactive routes to list_by_subtype_in_experiment with the right query params."""
100+ result = runner .invoke (app , ["--format" , "json" , "task" , "list" , "--subtype" , "interactive" ])
101+ assert result .exit_code == 0
102+ called_url = mock_api_get .call_args .args [0 ]
103+ assert "list_by_subtype_in_experiment" in called_url
104+ assert "subtype=interactive" in called_url
105+ assert "type=REMOTE" in called_url
106+
107+
108+ @patch ("transformerlab_cli.commands.task.api.get" , return_value = _mock_resp (SAMPLE_TASKS ))
109+ @patch ("transformerlab_cli.commands.task.require_current_experiment" , return_value = "exp1" )
110+ def test_task_list_rejects_unknown_subtype (_mock_exp , mock_api_get ):
111+ """--subtype <unknown> exits non-zero with an Allowed: ... error and does not hit the server."""
112+ result = runner .invoke (app , ["task" , "list" , "--subtype" , "cuckoo" ])
113+ assert result .exit_code != 0
114+ out = _cli_output (result )
115+ assert "Invalid value for '--subtype'" in out
116+ assert "Allowed: interactive" in out
117+ mock_api_get .assert_not_called ()
118+
119+
84120def test_build_launch_payload_includes_description ():
85121 """build_launch_payload forwards the description to the launch API body."""
86122 task = {"id" : "t1" , "name" : "finetune" , "experiment_id" : "exp1" , "run" : "python main.py" }
0 commit comments