|
| 1 | +"""Test LICENSE file is optional and excluded by default.""" |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from pathlib import Path |
| 6 | + |
| 7 | +import pytest |
| 8 | +from conftest import _make_data, _run_copy |
| 9 | + |
| 10 | + |
| 11 | +@pytest.fixture(scope="module") |
| 12 | +def generated_without_license() -> Path: |
| 13 | + """Generate project without LICENSE file (default behavior).""" |
| 14 | + data = _make_data({"project_name": "no_license_proj", "include_license": False}) |
| 15 | + return _run_copy(data, dst_name="no_license") |
| 16 | + |
| 17 | + |
| 18 | +@pytest.fixture(scope="module") |
| 19 | +def generated_with_license() -> Path: |
| 20 | + """Generate project with LICENSE file explicitly requested.""" |
| 21 | + data = _make_data( |
| 22 | + { |
| 23 | + "project_name": "with_license_proj", |
| 24 | + "include_license": True, |
| 25 | + } |
| 26 | + ) |
| 27 | + return _run_copy(data, dst_name="with_license") |
| 28 | + |
| 29 | + |
| 30 | +def test_license_excluded_by_default(generated_without_license: Path): |
| 31 | + """Test that LICENSE file is NOT included when include_license=false (default).""" |
| 32 | + license_path = generated_without_license / "LICENSE" |
| 33 | + assert not license_path.exists(), "LICENSE should not exist when include_license=false (default)" |
| 34 | + |
| 35 | + |
| 36 | +def test_license_included_when_requested(generated_with_license: Path): |
| 37 | + """Test that LICENSE file IS included when include_license=true.""" |
| 38 | + license_path = generated_with_license / "LICENSE" |
| 39 | + assert license_path.is_file(), "LICENSE should exist when include_license=true" |
| 40 | + |
| 41 | + |
| 42 | +def test_license_content_matches_template(generated_with_license: Path): |
| 43 | + """Test that generated LICENSE file contains expected content.""" |
| 44 | + license_path = generated_with_license / "LICENSE" |
| 45 | + content = license_path.read_text() |
| 46 | + assert "MIT License" in content, "LICENSE should contain MIT License header" |
| 47 | + assert "Copyright" in content, "LICENSE should contain copyright notice" |
0 commit comments