Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions cli/setup.cfg
Original file line number Diff line number Diff line change
@@ -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
62 changes: 62 additions & 0 deletions cli/test_cli.py
Original file line number Diff line number Diff line change
@@ -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!")