|
26 | 26 | SCRIPT = "setup-tasks" |
27 | 27 |
|
28 | 28 |
|
| 29 | +def test_installed_python_json_preserves_stock_tasks_template( |
| 30 | + tmp_path: Path, |
| 31 | +) -> None: |
| 32 | + """The tasks command's actual script must emit JSON for the stock template.""" |
| 33 | + from typer.testing import CliRunner |
| 34 | + |
| 35 | + from specify_cli import app |
| 36 | + |
| 37 | + project = tmp_path / "project" |
| 38 | + initialized = CliRunner().invoke( |
| 39 | + app, |
| 40 | + [ |
| 41 | + "init", str(project), "--integration", "codex", "--script", "py", |
| 42 | + "--ignore-agent-tools", "--non-interactive", |
| 43 | + ], |
| 44 | + ) |
| 45 | + assert initialized.exit_code == 0, initialized.output |
| 46 | + created = run( |
| 47 | + py_cmd(project, "create-new-feature", "--json", "Add user authentication"), |
| 48 | + project, |
| 49 | + ) |
| 50 | + assert created.returncode == 0, created.stderr |
| 51 | + plan = run(py_cmd(project, "setup-plan", "--json"), project) |
| 52 | + assert plan.returncode == 0, plan.stderr |
| 53 | + template = project / ".specify/templates/tasks-template.md" |
| 54 | + expected = template.read_bytes().decode("utf-8") |
| 55 | + assert "🎯" in expected |
| 56 | + env = clean_env() |
| 57 | + env["PYTHONIOENCODING"] = "cp1252" |
| 58 | + |
| 59 | + result = run(py_cmd(project, SCRIPT, "--json"), project, env) |
| 60 | + |
| 61 | + assert result.returncode == 0, result.stderr |
| 62 | + payload = json_stdout(result) |
| 63 | + assert payload["TASKS_TEMPLATE_CONTENT"] == expected |
| 64 | + assert Path(payload["TASKS_TEMPLATE"]) == template |
| 65 | + assert payload["AVAILABLE_DOCS"] == [] |
| 66 | + |
| 67 | + |
29 | 68 | def _setup_repo(tmp_path: Path) -> Path: |
30 | 69 | repo = make_repo(tmp_path) |
31 | 70 | install_scripts(repo, SCRIPT) |
|
0 commit comments