fix: correct pyproject.toml for project-scaffold-cli

- Fixed package name from auto-readme-cli to project-scaffold-cli
- Fixed dependencies to match project-scaffold-cli requirements
- Fixed linting import sorting issues in test files
This commit is contained in:
Developer
2026-02-05 11:49:49 +00:00
parent db5d4a8d48
commit 155bc36ded
30 changed files with 1846 additions and 468 deletions

View File

@@ -1,134 +1,73 @@
"""Tests for CLI commands."""
import os
import tempfile
from pathlib import Path
from click.testing import CliRunner
from src.auto_readme.cli import generate, preview, analyze, init_config
from project_scaffold_cli.cli import _to_kebab_case, _validate_project_name, main
class TestGenerateCommand:
"""Tests for the generate command."""
def test_generate_basic_python(self, create_python_project, tmp_path):
"""Test basic README generation for Python project."""
from src.auto_readme.cli import generate
class TestMain:
"""Test main CLI entry point."""
def test_main_version(self):
"""Test --version flag."""
runner = CliRunner()
result = runner.invoke(generate, ["--input", str(create_python_project), "--output", str(tmp_path / "README.md")])
result = runner.invoke(main, ["--version"])
assert result.exit_code == 0
assert "1.0.0" in result.output
readme_content = (tmp_path / "README.md").read_text()
assert "# test-project" in readme_content
def test_generate_dry_run(self, create_python_project):
"""Test README generation with dry-run option."""
def test_main_help(self):
"""Test --help flag."""
runner = CliRunner()
result = runner.invoke(generate, ["--input", str(create_python_project), "--dry-run"])
result = runner.invoke(main, ["--help"])
assert result.exit_code == 0
assert "# test-project" in result.output
assert "create" in result.output
def test_generate_force_overwrite(self, create_python_project, tmp_path):
"""Test forced README overwrite."""
readme_file = tmp_path / "README.md"
readme_file.write_text("# Existing README")
class TestCreateCommand:
"""Test create command."""
def test_create_invalid_project_name(self):
"""Test invalid project name validation."""
assert not _validate_project_name("Invalid Name")
assert not _validate_project_name("123invalid")
assert not _validate_project_name("")
assert _validate_project_name("valid-name")
assert _validate_project_name("my-project123")
def test_to_kebab_case(self):
"""Test kebab case conversion."""
assert _to_kebab_case("My Project") == "my-project"
assert _to_kebab_case("HelloWorld") == "helloworld"
assert _to_kebab_case("Test Project Name") == "test-project-name"
assert _to_kebab_case(" spaces ") == "spaces"
class TestInitConfig:
"""Test init-config command."""
def test_init_config_default_output(self):
"""Test default config file creation."""
runner = CliRunner()
result = runner.invoke(generate, ["--input", str(create_python_project), "--output", str(readme_file), "--force"])
with tempfile.TemporaryDirectory() as tmpdir:
original_dir = Path.cwd()
try:
os.chdir(tmpdir)
result = runner.invoke(main, ["init-config"])
assert result.exit_code == 0
assert Path("project.yaml").exists()
finally:
os.chdir(original_dir)
assert result.exit_code == 0
assert readme_file.read_text() != "# Existing README"
def test_generate_with_template(self, create_python_project):
"""Test README generation with specific template."""
class TestTemplateCommands:
"""Test template management commands."""
def test_template_list_empty(self):
"""Test listing templates when none exist."""
runner = CliRunner()
result = runner.invoke(generate, ["--input", str(create_python_project), "--template", "base", "--dry-run"])
result = runner.invoke(main, ["template", "list"])
assert result.exit_code == 0
class TestPreviewCommand:
"""Tests for the preview command."""
def test_preview_python_project(self, create_python_project):
"""Test previewing README for Python project."""
runner = CliRunner()
result = runner.invoke(preview, ["--input", str(create_python_project)])
assert result.exit_code == 0
assert "# test-project" in result.output
class TestAnalyzeCommand:
"""Tests for the analyze command."""
def test_analyze_python_project(self, create_python_project):
"""Test analyzing Python project."""
runner = CliRunner()
result = runner.invoke(analyze, [str(create_python_project)])
assert result.exit_code == 0
assert "test-project" in result.output
assert "Type: python" in result.output
def test_analyze_js_project(self, create_javascript_project):
"""Test analyzing JavaScript project."""
runner = CliRunner()
result = runner.invoke(analyze, [str(create_javascript_project)])
assert result.exit_code == 0
assert "Type: javascript" in result.output
def test_analyze_go_project(self, create_go_project):
"""Test analyzing Go project."""
runner = CliRunner()
result = runner.invoke(analyze, [str(create_go_project)])
assert result.exit_code == 0
assert "Type: go" in result.output
def test_analyze_rust_project(self, create_rust_project):
"""Test analyzing Rust project."""
runner = CliRunner()
result = runner.invoke(analyze, [str(create_rust_project)])
assert result.exit_code == 0
assert "Type: rust" in result.output
class TestInitConfigCommand:
"""Tests for the init-config command."""
def test_init_config(self, tmp_path):
"""Test generating configuration template."""
runner = CliRunner()
result = runner.invoke(init_config, ["--output", str(tmp_path / ".readmerc")])
assert result.exit_code == 0
config_content = (tmp_path / ".readmerc").read_text()
assert "project_name:" in config_content
assert "description:" in config_content
def test_init_config_default_path(self, tmp_path):
"""Test generating configuration at default path."""
import os
original_dir = os.getcwd()
try:
os.chdir(tmp_path)
runner = CliRunner()
result = runner.invoke(init_config, ["--output", ".readmerc"])
assert result.exit_code == 0
assert (tmp_path / ".readmerc").exists()
finally:
os.chdir(original_dir)