diff --git a/cli/setup.cfg b/cli/setup.cfg new file mode 100644 index 000000000..4d676f95c --- /dev/null +++ b/cli/setup.cfg @@ -0,0 +1,25 @@ +[flake8] +max-line-length = 88 +extend-ignore = + # E203: whitespace before ':' (conflicts with black) + E203, + # W503: line break before binary operator (conflicts with black) + W503 +exclude = + .git, + __pycache__, + .venv, + venv, + .env, + env + +[isort] +profile = black +multi_line_output = 3 +line_length = 88 + +[mypy] +python_version = 3.8 +warn_return_any = True +warn_unused_configs = True +ignore_missing_imports = True diff --git a/cli/test_cli.py b/cli/test_cli.py new file mode 100644 index 000000000..f48f17e30 --- /dev/null +++ b/cli/test_cli.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +"""Basic tests for the CLI module.""" + +import os +import subprocess +import sys + + +def test_cli_help(): + """Test that the CLI shows help.""" + result = subprocess.run( + [sys.executable, "cli.py", "--help"], + capture_output=True, + text=True, + cwd=os.path.dirname(__file__), + ) + assert result.returncode == 0 + assert "101 Linux Commands CLI" in result.stdout + + +def test_hello_command(): + """Test the hello command.""" + result = subprocess.run( + [sys.executable, "cli.py", "hello", "greet"], + capture_output=True, + text=True, + cwd=os.path.dirname(__file__), + ) + assert result.returncode == 0 + assert "Hello, World!" in result.stdout + + +def test_hello_command_with_name(): + """Test the hello command with a custom name.""" + result = subprocess.run( + [sys.executable, "cli.py", "hello", "greet", "--name", "Linux"], + capture_output=True, + text=True, + cwd=os.path.dirname(__file__), + ) + assert result.returncode == 0 + assert "Hello, Linux!" in result.stdout + + +def test_hello_help(): + """Test the hello command help.""" + result = subprocess.run( + [sys.executable, "cli.py", "hello", "--help"], + capture_output=True, + text=True, + cwd=os.path.dirname(__file__), + ) + assert result.returncode == 0 + assert "Hello command group" in result.stdout + + +if __name__ == "__main__": + test_cli_help() + test_hello_command() + test_hello_command_with_name() + test_hello_help() + print("✅ All tests passed!")