def test_main_with_passthrough_argument(mock_execute): # Arrange # Act main.main(["testcmd", "arg1"]) # Assert mock_execute.assert_called_with("testcmd", ["arg1"])
def test_main_with_sys_argv_parsing(mock_execute): # Arrange # Act main.main() # Assert mock_execute.assert_called_with("testcmd", ["arg1", "arg2"])
def test_main_with_single_argument(mock_execute): # Arrange # Act main.main(["testcmd"]) # Assert mock_execute.assert_called_with("testcmd", [])
def test_main_with_several_passthrough_arguments(mock_execute): # Arrange # Act main(['testcmd', 'arg1', 'arg2', 'arg3']) # Assert mock_execute.assert_called_with('testcmd', ['arg1', 'arg2', 'arg3'])
def test_main_with_single_argument(mock_execute): # Arrange # Act main(['testcmd']) # Assert mock_execute.assert_called_with('testcmd', [])
def test_main_with_sys_argv_parsing(mock_execute): # Arrange # Act main() # Assert mock_execute.assert_called_with('testcmd', ['arg1', 'arg2'])
def test_main_with_help_argument_and_command_name_calls_command_detail( mock_detail, mock_config, mock_exit): # Arrange config = get_sample_config() mock_config.return_value = (config, None) # Act main.main(["help", "testcmd"]) # Assert mock_detail.assert_called_with("testcmd", config["commands"]["testcmd"])
def test_main_with_help_argument_call_list_options(mock_list, mock_config, mock_exit): # Arrange config = get_sample_config() mock_config.return_value = (config, None) # Act main.main(["help"]) # Assert mock_list.assert_called_with(config)
def test_main_with_help_argument_and_bad_command_name_calls_list_options( mock_detail, mock_list_options, mock_config, mock_exit): # Arrange config = get_sample_config() mock_config.return_value = (config, None) # Act main.main(["help", "foo"]) # Assert mock_detail.assert_not_called() mock_list_options.assert_called_with(config)
def test_main_with_no_argument(): # Arrange # Act # Assert with pytest.raises(SystemExit): main([])