def test_cli_help_forge_plugin_command(mock_run_forge_plugin, mock_command_names): mock_args = 'forge plugin1 -h'.split() with patch('sys.argv', mock_args), pytest.raises(SystemExit): inject_forge_plugins() forge_cli() mock_run_forge_plugin.assert_called_once_with(['plugin1', '-h'])
def test_cli_update_with_extra_args(mock_pipx_update): mock_args = 'forge update -n plugin-name arg1 val1 arg2 val2 '.split() with patch('sys.argv', mock_args), pytest.raises(SystemExit): forge_cli() mock_pipx_update.assert_called_once_with( name='forge-plugin-name', extra_args=['arg1', 'val1', 'arg2', 'val2'] )
def test_cli_add_with_extra_args(mock_pipx_install): mock_args = 'forge add -s some-source arg1 val1 arg2 val2'.split() with patch('sys.argv', mock_args), pytest.raises(SystemExit): forge_cli() mock_pipx_install.assert_called_once_with( source='some-source', extra_args=['arg1', 'val1', 'arg2', 'val2'] )
def test_cli_help_forge_core_command(mock_echo, mock_command_names): mock_args = 'forge add -h'.split() with patch('sys.argv', mock_args), pytest.raises(SystemExit): forge_cli() mock_echo.assert_called_once() assert str(mock_echo.mock_calls[0].args[0]).split('\n')[0] == 'Usage: forge add [OPTIONS] [PIPX_ARGS]...'
def test_cli_help_forge(mock_echo): mock_args = 'forge -h'.split() with patch('sys.argv', mock_args), pytest.raises(SystemExit): forge_cli() mock_echo.assert_called_once() assert str(mock_echo.mock_calls[0].args[0]).split('\n')[0] == 'Usage: forge [OPTIONS] COMMAND [ARGS]...'
def test_cli_remove_with_extra_args(uninstall_from_pipx): mock_args = 'forge remove -n plugin-name arg1 val1 arg2 val2 '.split() with patch('sys.argv', mock_args), pytest.raises(SystemExit): forge_cli() uninstall_from_pipx.assert_called_once_with( plugin_name='forge-plugin-name', extra_args=['arg1', 'val1', 'arg2', 'val2'] )
def main() -> None: """ Error-handled entry point for cli entry point """ try: inject_forge_plugins() forge_cli() # pylint: disable=no-value-for-parameter except PluginManagementFatalException: sys.exit(1) except PluginManagementWarnException: sys.exit(0)
def test_cli_update_all_since_no_name_given_with_extra_args(mock_get_plugins, mock_pipx_update): mock_get_plugins.return_value = [ {"main_package": {"package": "forge-plugin1"}}, {"main_package": {"package": "forge-plugin2"}} ] mock_args = 'forge update arg1 val1'.split() with patch('sys.argv', mock_args), pytest.raises(SystemExit): forge_cli() assert mock_pipx_update.mock_calls == [ call(name='forge-plugin1', extra_args=['arg1', 'val1']), call(name='forge-plugin2', extra_args=['arg1', 'val1']) ]
def test_cli_remove_all_since_no_name_given(mock_get_plugins, mocked_uninstall_from_pipx): mock_get_plugins.return_value = [ {"main_package": {"package": "forge-plugin1"}}, {"main_package": {"package": "forge-plugin2"}} ] mock_args = 'forge remove'.split() with patch('sys.argv', mock_args), pytest.raises(SystemExit): forge_cli() assert mocked_uninstall_from_pipx.mock_calls == [ call(plugin_name='forge-plugin1', extra_args=[]), call(plugin_name='forge-plugin2', extra_args=[]) ]
def test_cli_no_command(mock_pipx_list): mock_args = 'forge'.split() with patch('sys.argv', mock_args), pytest.raises(SystemExit): forge_cli() mock_pipx_list.assert_called_once_with()
def test_cli_update(mock_pipx_update): mock_args = 'forge update --name plugin-name'.split() with patch('sys.argv', mock_args), pytest.raises(SystemExit): forge_cli() mock_pipx_update.assert_called_once_with(name='forge-plugin-name', extra_args=[])
def test_cli_add(mock_pipx_install): mock_args = 'forge add --source some-source'.split() with patch('sys.argv', mock_args), pytest.raises(SystemExit): forge_cli() mock_pipx_install.assert_called_once_with(source='some-source', extra_args=[])