test(cli): cover docs-only, aliases, stack hints, index failure, watch loop (closes #103)#109
Merged
Merged
Conversation
…h loop Closes #103. `tests/python/test_cli.py` did not exercise five documented public CLI behaviors. Add a dedicated `tests/python/test_cli_coverage.py` module covering each: - `StackAndProductHintInjectionTest` asserts `--stack` / `--product-name` flow into `product.stack` / `product.name` in the emitted project-map when `.starter-meta.json` is absent. - `JsonOnlyAndChangedOnlyAliasesTest` covers the orchestrator-facing compatibility aliases — `--json-only` keeps docs disabled, `--changed-only` forces incremental refresh. - `DocsOnlyShortCircuitTest` confirms `--docs-only` on `index` renders the Markdown wiki without rewriting the JSON payload. - `IndexFailureBoundaryTest` patches `_run_index` to throw and asserts the `index` CLI returns exit 1 with a stable `status="failed"` JSON payload carrying the underlying error message. - `WatchLoopExitsOnInterruptTest` is a bounded test for `_watch`: it monkey-patches `time.sleep` to raise `KeyboardInterrupt` on the first tick so the loop exits via its documented branch without crashing. Each test asserts observable artifact contents or the JSON result, not internal call counts. https://claude.ai/code/session_01JdmemqddwFnvbceWyuDE8m
Contributor
There was a problem hiding this comment.
Pull request overview
Fecha a lacuna de cobertura dos caminhos “documentados” da CLI Python (Issue #103), adicionando uma nova suíte de testes que exercita flags/rotas que eram parte do contrato público, mas não tinham assertions de saída observável.
Changes:
- Adiciona
tests/python/test_cli_coverage.pycom cenários para--docs-only, aliases--json-only/--changed-only, injeção de hints--stack/--product-name, boundary de falha doindex, e um teste bounded do loop de_watch. - Os testes focam em efeitos observáveis (arquivos gerados e/ou payload JSON emitido), e não em contagem de chamadas internas.
Comment on lines
+83
to
+86
| def test_json_only_keeps_docs_disabled(self) -> None: | ||
| code, _, _ = _run([ | ||
| "index", str(self.dir), "--json", "--json-only", | ||
| ]) |
Comment on lines
+118
to
+126
| project_map_path = self.dir / ".simplicio" / "project-map.json" | ||
| before = project_map_path.read_text() | ||
| code, _, _ = _run([ | ||
| "index", str(self.dir), "--docs-only", "--json", | ||
| ]) | ||
| self.assertEqual(code, 0) | ||
| after = project_map_path.read_text() | ||
| # JSON payload is not rewritten by --docs-only. | ||
| self.assertEqual(before, after) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resumo
Fecha #103. Adiciona testes para os 5 caminhos documentados da CLI Python que não tinham assertion.
Mudanças
tests/python/test_cli_coverage.pynovo, 6 testes (5 cenários + 1 boundary do watch):StackAndProductHintInjectionTest—--stack/--product-namefluem paraproduct.stack/product.namequando.starter-meta.jsonestá ausente.JsonOnlyAndChangedOnlyAliasesTest—--json-onlymantém docs desligado;--changed-onlyforçaincremental.DocsOnlyShortCircuitTest—--docs-onlynoindexrenderiza Markdown sem reescrever o JSON.IndexFailureBoundaryTest—mock.patchem_run_indexlança exception → CLI retornaexit 1+ JSONstatus="failed"comerror.WatchLoopExitsOnInterruptTest—_watchbounded test (patch emtime.sleeplançandoKeyboardInterrupt) garante saída limpa.Cada teste asserta sobre output observável (conteúdo do artifact ou JSON), não call counts internos.
Validação
test_cli_coveragegit commitno fixture pelo signing server; idêntica ao baseline emmain)Refs #103.
https://claude.ai/code/session_01JdmemqddwFnvbceWyuDE8m
Generated by Claude Code