示例#1
0
def test_main_with_passthrough_argument(mock_execute):
    # Arrange
    # Act
    main.main(["testcmd", "arg1"])

    # Assert
    mock_execute.assert_called_with("testcmd", ["arg1"])
示例#2
0
def test_main_with_sys_argv_parsing(mock_execute):
    # Arrange
    # Act
    main.main()

    # Assert
    mock_execute.assert_called_with("testcmd", ["arg1", "arg2"])
示例#3
0
def test_main_with_single_argument(mock_execute):
    # Arrange
    # Act
    main.main(["testcmd"])

    # Assert
    mock_execute.assert_called_with("testcmd", [])
示例#4
0
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'])
示例#5
0
def test_main_with_single_argument(mock_execute):
    # Arrange
    # Act
    main(['testcmd'])

    # Assert
    mock_execute.assert_called_with('testcmd', [])
示例#6
0
def test_main_with_sys_argv_parsing(mock_execute):
    # Arrange
    # Act
    main()

    # Assert
    mock_execute.assert_called_with('testcmd', ['arg1', 'arg2'])
示例#7
0
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"])
示例#8
0
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)
示例#9
0
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)
示例#10
0
def test_main_with_no_argument():
    # Arrange
    # Act
    # Assert
    with pytest.raises(SystemExit):
        main([])