tools, instructions: Abhängigkeiten - Tests biegen config-Pfade über set_config_path um (pytest 9.2), Teardown-Wache; Befehlsreferenz mit typer 0.29 neu erzeugt, typer>=0.29.1, kein click mehr in Tests (#243); 10.2.0-beta.2
CI / verify (push) Successful in 8m31s
CI / pwsh (push) Successful in 2m51s
Converters / converters (push) Successful in 9m42s
Release / converters (push) Successful in 26s
Release / release (push) Successful in 41s
Release / wiki-mirror (push) Skipped
CI / verify (push) Successful in 8m31s
CI / pwsh (push) Successful in 2m51s
Converters / converters (push) Successful in 9m42s
Release / converters (push) Successful in 26s
Release / release (push) Successful in 41s
Release / wiki-mirror (push) Skipped
Files changed: - CHANGES.md - VERSION - docs/reference/commands/configuration.md - docs/reference/commands/content-migrations.md - docs/reference/commands/distribution-and-versioning.md - docs/reference/commands/exports.md - docs/reference/commands/finding-and-checking.md - docs/reference/commands/git.md - docs/reference/commands/pages.md - docs/reference/commands/raw-material-and-uploads.md - docs/reference/commands/types-instructions-and-docs.md - instructions/dev/testing-conventions.md - tools/chemenu/config.py - tools/chemenu/tests/conftest.py - tools/chemenu/tests/test_api.py - tools/chemenu/tests/test_backup.py - tools/chemenu/tests/test_cite_cmd.py - tools/chemenu/tests/test_collect.py - tools/chemenu/tests/test_config_shapes.py - tools/chemenu/tests/test_conventions.py - tools/chemenu/tests/test_corpus_cache.py - tools/chemenu/tests/test_dist_cmd.py - tools/chemenu/tests/test_dist_upgrade.py - tools/chemenu/tests/test_docs_verify.py - tools/chemenu/tests/test_doctor.py - tools/chemenu/tests/test_export_guidelines.py - tools/chemenu/tests/test_export_run.py - tools/chemenu/tests/test_git_publish.py - tools/chemenu/tests/test_hermetic_env.py - tools/chemenu/tests/test_install_doc.py - tools/chemenu/tests/test_instructions_cmd.py - tools/chemenu/tests/test_kb_collections.py - tools/chemenu/tests/test_legacy_settings.py - tools/chemenu/tests/test_lint.py - tools/chemenu/tests/test_log_append.py - tools/chemenu/tests/test_migrate_cmd.py - tools/chemenu/tests/test_new_page.py - tools/chemenu/tests/test_page_ops.py - tools/chemenu/tests/test_pipeline_l0.py - tools/chemenu/tests/test_preflight.py - tools/chemenu/tests/test_provenance.py - tools/chemenu/tests/test_reference_doc.py - tools/chemenu/tests/test_review.py - tools/chemenu/tests/test_settings.py - tools/chemenu/tests/test_task_cmd.py - tools/chemenu/tests/test_telemetry_policy.py - tools/chemenu/tests/test_toc.py - tools/chemenu/tests/test_touch.py - tools/chemenu/tests/test_upload_cmd.py - tools/chemenu/tests/test_version_cmd.py - tools/chemenu/tests/test_work_cmd.py - tools/requirements.txt Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015uxGFdBAmyA23g1isCtGEY
This commit is contained in:
1 parent
832056a0b0
commit
0fce67e6b9
52 files changed
+546
-337
No files matched your search
+2
-1
@@ -14,7 +14,7 @@ place only: `instructions/dev/version-parts.md` § The candidate model.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 10.2.0-beta.1 - 2026-11-17 - Ingest: Präzisierungen des Operators als Begleitdatei im Bundle der Quelle - neuer Befehl raw clarify (#241)
|
## 10.2.0-beta.2 - 2026-11-18 - Abhängigkeiten: Testsuite läuft unter pytest 9.2, Befehlshilfe und Referenz folgen typer 0.29 - Untergrenze typer>=0.29.1 (#243)
|
||||||
|
|
||||||
**Author:** Torben Nehmer
|
**Author:** Torben Nehmer
|
||||||
|
|
||||||
@@ -22,6 +22,7 @@ place only: `instructions/dev/version-parts.md` § The candidate model.
|
|||||||
**Medium impact**
|
**Medium impact**
|
||||||
- Reine Lesevorgänge schreiben keinen Log-Eintrag mehr, und ein offener Log-Eintrag allein lässt den Katalog beim Abgleich unangetastet
|
- Reine Lesevorgänge schreiben keinen Log-Eintrag mehr, und ein offener Log-Eintrag allein lässt den Katalog beim Abgleich unangetastet
|
||||||
- Ingest: Präzisierungen des Operators als Begleitdatei im Bundle der Quelle - neuer Befehl raw clarify (#241)
|
- Ingest: Präzisierungen des Operators als Begleitdatei im Bundle der Quelle - neuer Befehl raw clarify (#241)
|
||||||
|
- Abhängigkeiten: Testsuite läuft unter pytest 9.2, Befehlshilfe und Referenz folgen typer 0.29 - Untergrenze typer>=0.29.1 (#243)
|
||||||
|
|
||||||
**Low impact**
|
**Low impact**
|
||||||
- Publish-, Sync-Hilfe und Log-Vorlage nennen den reinen Log-Zusatz beim Abgleich
|
- Publish-, Sync-Hilfe und Log-Vorlage nennen den reinen Log-Zusatz beim Abgleich
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ Set one value of the tiered settings, in the file its tier names.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
key <section>.<field> [required]
|
key <str> <section>.<field> [required]
|
||||||
value The plain value; a string as given, anything else as JSON.
|
value <str> The plain value; a string as given, anything else as JSON.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--ref <str> A reference instead of a value: <name> or
|
--ref <str> A reference instead of a value: <name> or
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ Compare `kb/` against a git revision on the invariants a content migration must
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
--from <str> Git revision to compare against, e.g. HEAD [required]
|
--from <str> Git revision to compare against, e.g. HEAD [required]
|
||||||
--path <str> Limit to a subtree, repeatable (e.g. kb/concepts)
|
--path <list[str]> Limit to a subtree, repeatable (e.g. kb/concepts)
|
||||||
--expect-body-change Also report pages whose body did not change at all
|
--expect-body-change Also report pages whose body did not change at all
|
||||||
--json Print the diff as JSON
|
--json Print the diff as JSON
|
||||||
--fail-on-error Exit 1 if any invariant changed
|
--fail-on-error Exit 1 if any invariant changed
|
||||||
@@ -173,7 +173,7 @@ Record one migration as applied, advancing `kb_version` in `.wikitool-kb.json`.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
version The migration's target version, e.g. 1.4.0 [required]
|
version <str> The migration's target version, e.g. 1.4.0 [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--pages <int> How many pages it touched
|
--pages <int> How many pages it touched
|
||||||
@@ -227,7 +227,7 @@ Declare `kb_version` once, for an instance predating `.wikitool-kb.json`.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
version The shape this instance's content is already in [required]
|
version <str> The shape this instance's content is already in [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--force Overwrite an existing declaration (not a substitute for `done`)
|
--force Overwrite an existing declaration (not a substitute for `done`)
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ Write a contentless, distributable copy of this repo's machinery.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
target Directory to write the distribution into. Must not exist, or must be
|
target <path> Directory to write the distribution into. Must not exist, or
|
||||||
empty. [required]
|
must be empty. [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--dry-run List what would be written, without writing anything.
|
--dry-run List what would be written, without writing anything.
|
||||||
@@ -98,8 +98,8 @@ Take shipped templates as this instance's own: copy each to its unsuffixed name.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
templates... Templates to adopt. Default: every collection contract and page
|
templates... <list[Path]> Templates to adopt. Default: every collection
|
||||||
type-spec template.
|
contract and page type-spec template.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--dry-run List what would be copied, without writing anything.
|
--dry-run List what would be copied, without writing anything.
|
||||||
@@ -154,29 +154,30 @@ Apply a stack update `dist export` produced - the write half of `version check`.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
source An extracted distribution directory, or a release .tar.gz archive - or
|
source <path> An extracted distribution directory, or a release .tar.gz
|
||||||
use --latest
|
archive - or use --latest
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--latest Download the release the feed announces as latest
|
--latest Download the release the feed announces as latest
|
||||||
instead of naming a <source>
|
instead of naming a <source>
|
||||||
--expect <str> With --latest: refuse, before downloading anything,
|
--expect <str> With --latest: refuse, before downloading
|
||||||
unless the feed's latest release is this version (the
|
anything, unless the feed's latest release is this
|
||||||
one `version notes` was read for)
|
version (the one `version notes` was read for)
|
||||||
--dry-run Classify and report, without writing anything
|
--dry-run Classify and report, without writing anything
|
||||||
--keep-local Proceed even with locally changed files - leave each one
|
--keep-local Proceed even with locally changed files - leave
|
||||||
untouched rather than aborting
|
each one untouched rather than aborting
|
||||||
--take-release <str> Overwrite this locally changed path with the release's
|
--take-release <list[str]> Overwrite this locally changed path with the
|
||||||
version, discarding the local change. Repeatable, and
|
release's version, discarding the local change.
|
||||||
each path must be one this run reports as locally
|
Repeatable, and each path must be one this run
|
||||||
changed. The counterpart to --keep-local, which keeps
|
reports as locally changed. The counterpart to
|
||||||
the change and reports it again on every future upgrade
|
--keep-local, which keeps the change and reports
|
||||||
--prune Accepted and ignored: files the new release no longer
|
it again on every future upgrade
|
||||||
ships are now deleted by default when unchanged since
|
--prune Accepted and ignored: files the new release no
|
||||||
install
|
longer ships are now deleted by default when
|
||||||
--pre Allow a pre-release (-beta.N) source tree - release.yml
|
unchanged since install
|
||||||
never publishes one
|
--pre Allow a pre-release (-beta.N) source tree -
|
||||||
-h, --help Show this message and exit.
|
release.yml never publishes one
|
||||||
|
-h, --help Show this message and exit.
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
@@ -503,8 +504,8 @@ List the running candidate's bump titles with their impact grade, or change one
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
indices... 1-based positions in the rendered bump list to regrade (see the
|
indices... <list[int]> 1-based positions in the rendered bump list to regrade
|
||||||
bare listing). Omit to just list.
|
(see the bare listing). Omit to just list.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--impact <str> high|medium|low - required together with indices
|
--impact <str> high|medium|low - required together with indices
|
||||||
|
|||||||
@@ -22,19 +22,19 @@ Render the guideline pages into one generated `GUIDELINES.md`, or push it into t
|
|||||||
**Options**
|
**Options**
|
||||||
|
|
||||||
```text
|
```text
|
||||||
-f, --field <str> Frontmatter predicate, repeatable (AND) - the same forms
|
-f, --field <list[str]> Frontmatter predicate, repeatable (AND) - the same
|
||||||
as `search --field`.
|
forms as `search --field`.
|
||||||
--kind <str> Shorthand for --field kind=<value>.
|
--kind <str> Shorthand for --field kind=<value>.
|
||||||
--subtype <str> Shorthand for --field subtype=<value>.
|
--subtype <str> Shorthand for --field subtype=<value>.
|
||||||
--collection <str> Shorthand for --field collection=<value>.
|
--collection <str> Shorthand for --field collection=<value>.
|
||||||
--tag <str> Shorthand for --field tags=<value>.
|
--tag <str> Shorthand for --field tags=<value>.
|
||||||
--push Write the file into the captured repositories (Guideline
|
--push Write the file into the captured repositories
|
||||||
Push Gate).
|
(Guideline Push Gate).
|
||||||
--bundle <path> Only the repository of this captured bundle under raw/;
|
--bundle <list[Path]> Only the repository of this captured bundle under
|
||||||
repeatable.
|
raw/; repeatable.
|
||||||
--confirm <str> The token from a prior exit 42, once a human has approved
|
--confirm <str> The token from a prior exit 42, once a human has
|
||||||
it.
|
approved it.
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
@@ -94,7 +94,7 @@ Write the derived, read-only reading copy of `kb/` into the folders the `export`
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
[TARGET]... Targets to run; default: every configured target.
|
[TARGET]... <list[str]> Targets to run; default: every configured target.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
|
|||||||
@@ -88,27 +88,27 @@ Find pages in `kb/` by text and/or frontmatter.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
text Text to search for. Omit it to run a pure frontmatter query.
|
text <str> Text to search for. Omit it to run a pure frontmatter query.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-f, --field <str> Frontmatter predicate, repeatable (AND). Forms:
|
-f, --field <list[str]> Frontmatter predicate, repeatable (AND). Forms:
|
||||||
field=value, field~substring, 'field>=value', 'field:*'
|
field=value, field~substring, 'field>=value',
|
||||||
(present), '!field' (absent).
|
'field:*' (present), '!field' (absent).
|
||||||
--kind <str> Shorthand for --field kind=<value>.
|
--kind <str> Shorthand for --field kind=<value>.
|
||||||
--subtype <str> Shorthand for --field subtype=<value>.
|
--subtype <str> Shorthand for --field subtype=<value>.
|
||||||
--collection <str> Shorthand for --field collection=<value>.
|
--collection <str> Shorthand for --field collection=<value>.
|
||||||
--tag <str> Shorthand for --field tags=<value>.
|
--tag <str> Shorthand for --field tags=<value>.
|
||||||
--regex Treat the query as a regex. Off by default: terms are
|
--regex Treat the query as a regex. Off by default: terms are
|
||||||
literal.
|
literal.
|
||||||
--limit <int> Maximum number of results. 0 for no limit. A capped result
|
--limit <int> Maximum number of results. 0 for no limit. A capped
|
||||||
says so. [default: 50]
|
result says so. [default: 50]
|
||||||
--sort <str> Sort by a result field; prefix with '-' to reverse, e.g.
|
--sort <str> Sort by a result field; prefix with '-' to reverse,
|
||||||
-modified.
|
e.g. -modified.
|
||||||
--backend <str> Search backend(s), comma-separated. Default 'rg' (or
|
--backend <str> Search backend(s), comma-separated. Default 'rg' (or
|
||||||
$WIKITOOL_SEARCH_BACKEND).
|
$WIKITOOL_SEARCH_BACKEND).
|
||||||
--matches Print the matching lines under each result.
|
--matches Print the matching lines under each result.
|
||||||
--json Print the results as JSON.
|
--json Print the results as JSON.
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ Reconcile with `<remote>/<branch>`, then stage all changes, commit, and push.
|
|||||||
at/above which clearance is required. [default: 10]
|
at/above which clearance is required. [default: 10]
|
||||||
--remote <str> Git remote to push to [default: origin]
|
--remote <str> Git remote to push to [default: origin]
|
||||||
--branch <str> Branch to push [default: main]
|
--branch <str> Branch to push [default: main]
|
||||||
--path <str> Limit this publish to a path (repeatable). Lets a
|
--path <list[str]> Limit this publish to a path (repeatable). Lets a
|
||||||
large change be committed in reviewable batches
|
large change be committed in reviewable batches
|
||||||
instead of one opaque commit - the Mass-Update Gate
|
instead of one opaque commit - the Mass-Update Gate
|
||||||
then counts only the files in scope.
|
then counts only the files in scope.
|
||||||
|
|||||||
@@ -33,23 +33,24 @@ Scaffold a new wiki page of any type.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
type_name Type name, e.g. entity|concept|source|comparison (see `wikitool
|
type_name <str> Type name, e.g. entity|concept|source|comparison (see
|
||||||
types list`) [required]
|
`wikitool types list`) [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--name <str> Page title (a type's title_prefix is added automatically)
|
--name <str> Page title (a type's title_prefix is added automatically)
|
||||||
[required]
|
[required]
|
||||||
--type <str> Override the type-spec path (defaults to the one named by
|
--type <str> Override the type-spec path (defaults to the one named by
|
||||||
TYPE_NAME)
|
TYPE_NAME)
|
||||||
--set <str> Frontmatter field, repeatable: --set entity_type=tool --set
|
--set <list[str]> Frontmatter field, repeatable: --set entity_type=tool --set
|
||||||
tags=a,b. Array values split on commas (escape a literal one as
|
tags=a,b. Array values split on commas (escape a literal
|
||||||
\,); repeating --set for an array field appends instead of
|
one as \,); repeating --set for an array field appends
|
||||||
replacing
|
instead of replacing
|
||||||
--resume `project` only: confirm a human has completed the manual tracker
|
--resume `project` only: confirm a human has completed the manual
|
||||||
step an earlier HumanInterventionRequired refusal asked for, so
|
tracker step an earlier HumanInterventionRequired refusal
|
||||||
this run continues to page creation instead of refusing the now-
|
asked for, so this run continues to page creation instead
|
||||||
existing tracker project as a collision.
|
of refusing the now-existing tracker project as a
|
||||||
-h, --help Show this message and exit.
|
collision.
|
||||||
|
-h, --help Show this message and exit.
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
@@ -302,26 +303,27 @@ Bump a page's `modified:` date and optionally rewrite its other frontmatter fiel
|
|||||||
**Options**
|
**Options**
|
||||||
|
|
||||||
```text
|
```text
|
||||||
--page <str> Exact page title, e.g. 'Docker Cheatsheet' [required]
|
--page <str> Exact page title, e.g. 'Docker Cheatsheet' [required]
|
||||||
--summary <str> Replace the page's 1-line summary
|
--summary <str> Replace the page's 1-line summary
|
||||||
--provenance <str> Replace the page's provenance marker
|
--provenance <str> Replace the page's provenance marker
|
||||||
(sourced|general|mixed)
|
(sourced|general|mixed)
|
||||||
--date <str> Date to record (YYYY-MM-DD). `modified:` defaults to
|
--date <str> Date to record (YYYY-MM-DD). `modified:` defaults to
|
||||||
today; a source's `date:` is its publication date and
|
today; a source's `date:` is its publication date and
|
||||||
changes only when given here.
|
changes only when given here.
|
||||||
--set <str> Replace a frontmatter field, repeatable: --set tags=a,b.
|
--set <list[str]> Replace a frontmatter field, repeatable: --set tags=a,b.
|
||||||
Array values split on commas (escape a literal one as \,);
|
Array values split on commas (escape a literal one as
|
||||||
repeating --set for one array field appends within this
|
\,); repeating --set for one array field appends within
|
||||||
call. Page-reference fields belong to `xref`, not here
|
this call. Page-reference fields belong to `xref`, not
|
||||||
--add <str> Append elements to an array field without naming the whole
|
here
|
||||||
list: --add tags=x. Elements already present are left
|
--add <list[str]> Append elements to an array field without naming the
|
||||||
alone
|
whole list: --add tags=x. Elements already present are
|
||||||
--remove <str> Drop elements from an array field: --remove tags=x.
|
left alone
|
||||||
Removing an absent element succeeds and says so
|
--remove <list[str]> Drop elements from an array field: --remove tags=x.
|
||||||
--no-date Only change the given fields; leave the modified/date
|
Removing an absent element succeeds and says so
|
||||||
field alone
|
--no-date Only change the given fields; leave the modified/date
|
||||||
--dry-run Preview the new frontmatter instead of writing
|
field alone
|
||||||
-h, --help Show this message and exit.
|
--dry-run Preview the new frontmatter instead of writing
|
||||||
|
-h, --help Show this message and exit.
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ Capture a web page the user names into `incoming/`: the HTML as received plus a
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
url The http(s) URL to fetch
|
url <str> The http(s) URL to fetch
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--html <path> Derive the text from this HTML file under incoming/ (saved from
|
--html <path> Derive the text from this HTML file under incoming/ (saved from
|
||||||
@@ -117,7 +117,7 @@ Let the user sign in to a website once, in a visible browser window, and store t
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
host The website's host, such as www.example.org [required]
|
host <str> The website's host, such as www.example.org [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
@@ -172,7 +172,7 @@ Derive reading text from a PDF, e-mail, Office file or web page in `incoming/`,
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
path A file or a folder directly in incoming/ [required]
|
path <path> A file or a folder directly in incoming/ [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--name <str> Folder stem for a single file instead of the file's own stem
|
--name <str> Folder stem for a single file instead of the file's own stem
|
||||||
@@ -237,13 +237,13 @@ Write the operator's answers to an ingest's questions about a source as a compan
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
entry A file or folder directly in incoming/ (omit with --page)
|
entry <path> A file or folder directly in incoming/ (omit with --page)
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--item <str> One answer, one line; repeat for more
|
--item <list[str]> One answer, one line; repeat for more
|
||||||
--page <str> Clarify the source of this existing page instead of an entry of
|
--page <str> Clarify the source of this existing page instead of an
|
||||||
incoming/
|
entry of incoming/
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
@@ -295,19 +295,19 @@ Capture documentation from a git repository into `incoming/<bundle>/`, with a ma
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
repo_url The repository URL (ssh://, https:// or user@host:path)
|
repo_url <str> The repository URL (ssh://, https:// or user@host:path)
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--ref <str> A branch name (main) or a tag pattern (v*)
|
--ref <str> A branch name (main) or a tag pattern (v*)
|
||||||
--path <str> A glob over the repository's paths; repeatable
|
--path <list[str]> A glob over the repository's paths; repeatable
|
||||||
--name <str> The bundle name - the folder in incoming/ and under raw/
|
--name <str> The bundle name - the folder in incoming/ and under raw/
|
||||||
--fidelity <str> How faithful the capture is (see `wikitool types describe
|
--fidelity <str> How faithful the capture is (see `wikitool types describe
|
||||||
source`)
|
source`)
|
||||||
--authority <str> What the material may claim about its subject (see
|
--authority <str> What the material may claim about its subject (see
|
||||||
`wikitool types describe source`)
|
`wikitool types describe source`)
|
||||||
--update <path> Capture the current state of this captured bundle under
|
--update <path> Capture the current state of this captured bundle under
|
||||||
raw/, from its own manifest
|
raw/, from its own manifest
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
@@ -470,9 +470,9 @@ Promote one or more files, or one folder, from `incoming/` into `raw/`.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
files... One or more files directly in incoming/, all belonging to the same
|
files... <list[Path]> One or more files directly in incoming/, all belonging
|
||||||
source - or one folder in incoming/, accepted whole as one source
|
to the same source - or one folder in incoming/,
|
||||||
[required]
|
accepted whole as one source [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--fidelity <str> How faithful the capture is (see `wikitool types
|
--fidelity <str> How faithful the capture is (see `wikitool types
|
||||||
@@ -571,7 +571,8 @@ Pull material from the configured `folder` and `command` intake channels into th
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
names... Channels to collect from; all pulled channels when none is named
|
names... <list[str]> Channels to collect from; all pulled channels when none
|
||||||
|
is named
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
@@ -674,7 +675,7 @@ Print one submission's manifest in full.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
submission_id A submission id from `upload list` [required]
|
submission_id <str> A submission id from `upload list` [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--json
|
--json
|
||||||
@@ -724,7 +725,7 @@ tools/wikitool upload show <id>
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
submission_id A submission id from `upload list` [required]
|
submission_id <str> A submission id from `upload list` [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--confirm <str> The token from a prior refusal, once a human has reviewed it
|
--confirm <str> The token from a prior refusal, once a human has reviewed it
|
||||||
@@ -779,7 +780,7 @@ Delete a submission's material, keeping only its ledger trail.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
submission_id A submission id from `upload list` [required]
|
submission_id <str> A submission id from `upload list` [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--reason <str> Why this submission was declined [required]
|
--reason <str> Why this submission was declined [required]
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ Print one type's full contract.
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Arguments:
|
Arguments:
|
||||||
name Type name, e.g. 'entity' (see `types list`) [required]
|
name <str> Type name, e.g. 'entity' (see `types list`) [required]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--json Print raw findings as JSON
|
--json Print raw findings as JSON
|
||||||
|
|||||||
@@ -66,6 +66,18 @@ Both corpus fixtures therefore repoint it: `raw_dir` and `kb_dir` each set
|
|||||||
access, so repointing `ROOT` carries `KB_DIR`, `RAW_DIR` and the rest with it. A new fixture
|
access, so repointing `ROOT` carries `KB_DIR`, `RAW_DIR` and the rest with it. A new fixture
|
||||||
that builds a tree does the same thing - that is the rule here, not a per-test judgment.
|
that builds a tree does the same thing - that is the rule here, not a per-test judgment.
|
||||||
|
|
||||||
|
**Repoint a path with `set_config_path(monkeypatch, name, value)` from `conftest.py`, never with
|
||||||
|
`monkeypatch.setattr(config, name, value)`.** The names `config` resolves rather than stores
|
||||||
|
(`config.MANAGED_PATHS`: `ROOT` and everything derived from it) break `setattr`'s undo in a way
|
||||||
|
that depends on the pytest version. Up to 9.1 it read the old value through the module
|
||||||
|
`__getattr__` and wrote the resolved path back as a real attribute, so the name stopped
|
||||||
|
following `resolve_root()`; from 9.2 it reads the module dict instead and undoes with `delattr`,
|
||||||
|
which raises, because `hermetic_environment` has already dropped the binding. The first was
|
||||||
|
silent for as long as it lasted; the second turned CI red on the first run that installed
|
||||||
|
pytest 9.2. `set_config_path` patches the module dict
|
||||||
|
as a dict, whose undo copes with either, and a `pytest_runtest_teardown` hook in `conftest.py`
|
||||||
|
fails any test that still leaves a managed path bound after `monkeypatch` is done.
|
||||||
|
|
||||||
`kb_dir` did not, until Gitea #44. Two things came of that. A test calling
|
`kb_dir` did not, until Gitea #44. Two things came of that. A test calling
|
||||||
`kb_state.write_kb_state()` overwrote the real `.wikitool-kb.json`, which `git status` made
|
`kb_state.write_kb_state()` overwrote the real `.wikitool-kb.json`, which `git status` made
|
||||||
visible within the minute. Quieter and worse: `lint`'s collection lookup resolved a page
|
visible within the minute. Quieter and worse: `lint`'s collection lookup resolved a page
|
||||||
@@ -135,7 +147,8 @@ Whenever you add or change a test under `tools/chemenu/tests/`.
|
|||||||
a prefix loop beside it, as `WIKITOOL_SECRET_*` has. A variable the tool reads and the fixture does not clear
|
a prefix loop beside it, as `WIKITOOL_SECRET_*` has. A variable the tool reads and the fixture does not clear
|
||||||
is the exact hole this whole file is about, reopened.
|
is the exact hole this whole file is about, reopened.
|
||||||
|
|
||||||
5. **Writing a fixture that builds a tree?** Repoint `config.ROOT` at it and call
|
5. **Writing a fixture that builds a tree?** Repoint `config.ROOT` at it with
|
||||||
|
`set_config_path(monkeypatch, "ROOT", tree)` and call
|
||||||
`use_shipped_type_specs(monkeypatch)`, as `raw_dir` and `kb_dir` do - see
|
`use_shipped_type_specs(monkeypatch)`, as `raw_dir` and `kb_dir` do - see
|
||||||
[Which tree a test writes into](#which-tree-a-test-writes-into). A fixture that returns a
|
[Which tree a test writes into](#which-tree-a-test-writes-into). A fixture that returns a
|
||||||
path without repointing hands the code under test the real repository.
|
path without repointing hands the code under test the real repository.
|
||||||
|
|||||||
+10
-8
@@ -142,12 +142,14 @@ def reset() -> None:
|
|||||||
"""Drop every assignment onto a managed path name, back to resolution.
|
"""Drop every assignment onto a managed path name, back to resolution.
|
||||||
|
|
||||||
The test suite calls this between tests, and it is not optional there.
|
The test suite calls this between tests, and it is not optional there.
|
||||||
`monkeypatch.setattr(config, "KB_DIR", tmp)` records the old value by
|
Up to pytest 9.1, `monkeypatch.setattr(config, "KB_DIR", tmp)` recorded
|
||||||
*reading* it - which resolves it - and its undo then writes that resolved
|
the old value by *reading* it - which resolves it - and its undo then
|
||||||
path back as a real attribute. The name is bound from then on, so the next
|
wrote that resolved path back as a real attribute. The name was bound from
|
||||||
caller to repoint only `ROOT` gets a `KB_DIR` still aimed at the previous
|
then on, so the next caller to repoint only `ROOT` got a `KB_DIR` still
|
||||||
tree: exactly the half-repointed state this module was rewritten to make
|
aimed at the previous tree: exactly the half-repointed state this module
|
||||||
unconstructible, rebuilt by the cleanup rather than by the test.
|
was rewritten to make unconstructible, rebuilt by the cleanup rather than
|
||||||
|
by the test. The suite now repoints through `conftest.set_config_path`,
|
||||||
|
which patches the module dict as a dict, and still resets as a backstop.
|
||||||
"""
|
"""
|
||||||
for name in MANAGED_PATHS:
|
for name in MANAGED_PATHS:
|
||||||
globals().pop(name, None)
|
globals().pop(name, None)
|
||||||
@@ -157,8 +159,8 @@ def __getattr__(name: str):
|
|||||||
"""Resolve `ROOT` and the paths under it on access (PEP 562).
|
"""Resolve `ROOT` and the paths under it on access (PEP 562).
|
||||||
|
|
||||||
Only reached for names *not* in the module dict, so an explicit assignment
|
Only reached for names *not* in the module dict, so an explicit assignment
|
||||||
- `monkeypatch.setattr(config, "ROOT", tmp)` - keeps working and now also
|
- `config.ROOT = tmp`, or the suite's `set_config_path` - keeps working and
|
||||||
carries the derived paths with it, which is the bug this replaces.
|
now also carries the derived paths with it, which is the bug this replaces.
|
||||||
"""
|
"""
|
||||||
if name == "ROOT":
|
if name == "ROOT":
|
||||||
return resolve_root()
|
return resolve_root()
|
||||||
|
|||||||
@@ -177,11 +177,13 @@ def hermetic_environment(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
|
|||||||
monkeypatch.setattr(toolpaths, "tools_file", lambda: home / toolpaths.FILE_NAME)
|
monkeypatch.setattr(toolpaths, "tools_file", lambda: home / toolpaths.FILE_NAME)
|
||||||
|
|
||||||
# The same hole as the environment above, one layer in: `config` resolves
|
# The same hole as the environment above, one layer in: `config` resolves
|
||||||
# its paths on access, and `monkeypatch.setattr(config, "KB_DIR", ...)`
|
# its paths on access, and an assignment onto one of them - a test that
|
||||||
# undoes itself by writing the *resolved* old path back as a real
|
# sets `config.KB_DIR = ...` by hand - outlives the test and hands the next
|
||||||
# attribute. That binding outlives the test and hands the next one a
|
# one a corpus directory belonging to the previous tree. Cleared on both
|
||||||
# corpus directory belonging to the previous tree. Cleared on both sides,
|
# sides, so neither a leak from before nor one from this test can be
|
||||||
# so neither a leak from before nor one from this test can be inherited.
|
# inherited. A test repoints a path with `set_config_path()` below, whose
|
||||||
|
# undo copes with this reset having run first; `pytest_runtest_teardown`
|
||||||
|
# fails any test that still leaves one bound after `monkeypatch` is done.
|
||||||
# One layer further in again: `conventions` parses `kb/CONVENTIONS.md` once
|
# One layer further in again: `conventions` parses `kb/CONVENTIONS.md` once
|
||||||
# and keys the result on the file's own path and stat, so a repointed
|
# and keys the result on the file's own path and stat, so a repointed
|
||||||
# `KB_DIR` cannot be answered out of it. `telemetry.policy` caches the same
|
# `KB_DIR` cannot be answered out of it. `telemetry.policy` caches the same
|
||||||
@@ -200,6 +202,61 @@ def hermetic_environment(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
|
|||||||
telemetry_policy.reset_cache()
|
telemetry_policy.reset_cache()
|
||||||
|
|
||||||
|
|
||||||
|
def set_config_path(monkeypatch: pytest.MonkeyPatch, name: str, value) -> None:
|
||||||
|
"""Repoint one of `config`'s managed paths for the rest of this test.
|
||||||
|
|
||||||
|
The only way a test assigns `config.ROOT`, `config.KB_DIR` or any other name
|
||||||
|
in `config.MANAGED_PATHS`. `monkeypatch.setattr(config, name, value)` is
|
||||||
|
wrong for these names under every pytest version, in two different ways:
|
||||||
|
|
||||||
|
- up to 9.1 it recorded the old value by *reading* the attribute, which the
|
||||||
|
module `__getattr__` resolves, and its undo wrote that resolved path back
|
||||||
|
as a real module attribute - the name stayed bound to the previous tree
|
||||||
|
and stopped following `resolve_root()`, silently;
|
||||||
|
- from 9.2 it records the module `__dict__` entry instead and undoes an
|
||||||
|
absent one with `delattr` - which raises, because `hermetic_environment`
|
||||||
|
has already dropped the binding with `config.reset()` by the time
|
||||||
|
`monkeypatch` tears down.
|
||||||
|
|
||||||
|
Patching the module dict as a dict avoids both: `setitem` records whether
|
||||||
|
the key was there and its undo deletes a missing key without complaint, so
|
||||||
|
afterwards the name is bound exactly when it was bound before. The guard in
|
||||||
|
`pytest_runtest_teardown` below fails any test that leaves one bound.
|
||||||
|
"""
|
||||||
|
if name not in config.MANAGED_PATHS:
|
||||||
|
raise ValueError(f"{name!r} is not a managed path of chemenu.config")
|
||||||
|
monkeypatch.setitem(vars(config), name, value)
|
||||||
|
|
||||||
|
|
||||||
|
def bound_config_paths() -> list[str]:
|
||||||
|
"""The managed path names currently assigned on `config` rather than resolved."""
|
||||||
|
return [name for name in config.MANAGED_PATHS if name in vars(config)]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.hookimpl(wrapper=True)
|
||||||
|
def pytest_runtest_teardown(item, nextitem):
|
||||||
|
"""Fail a test that leaves a managed `config` path bound behind it.
|
||||||
|
|
||||||
|
A hook wrapper rather than a fixture, because it has to look *after*
|
||||||
|
`monkeypatch` has undone its patches, and `monkeypatch` is torn down after
|
||||||
|
every fixture that uses it. `hermetic_environment` drops every binding when
|
||||||
|
the next test sets up, so a test starts with none - which makes "none
|
||||||
|
after teardown" the same thing as "the same as before". A leak is reset
|
||||||
|
before the failure is raised, so it does not spread to the next test.
|
||||||
|
"""
|
||||||
|
result = yield
|
||||||
|
leaked = bound_config_paths()
|
||||||
|
if leaked:
|
||||||
|
config.reset()
|
||||||
|
raise AssertionError(
|
||||||
|
f"{item.nodeid} left chemenu.config path(s) bound after teardown: "
|
||||||
|
f"{', '.join(leaked)}. Repoint them with "
|
||||||
|
"`conftest.set_config_path(monkeypatch, name, value)`, never with "
|
||||||
|
"`monkeypatch.setattr(config, name, value)`."
|
||||||
|
)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def use_shipped_type_specs(monkeypatch: pytest.MonkeyPatch) -> None:
|
def use_shipped_type_specs(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||||
"""Keep the shipped `types/` reachable for a test that repoints `ROOT`.
|
"""Keep the shipped `types/` reachable for a test that repoints `ROOT`.
|
||||||
|
|
||||||
@@ -214,7 +271,7 @@ def use_shipped_type_specs(monkeypatch: pytest.MonkeyPatch) -> None:
|
|||||||
import time it held by accident, which is the same shape as the hole
|
import time it held by accident, which is the same shape as the hole
|
||||||
`raw_dir` was written to close, one layer down.
|
`raw_dir` was written to close, one layer down.
|
||||||
"""
|
"""
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", config._PACKAGE_ROOT / "types")
|
set_config_path(monkeypatch, "TYPES_DIR", config._PACKAGE_ROOT / "types")
|
||||||
monkeypatch.setattr(resolver, "_repo_root", config._PACKAGE_ROOT)
|
monkeypatch.setattr(resolver, "_repo_root", config._PACKAGE_ROOT)
|
||||||
|
|
||||||
|
|
||||||
@@ -259,7 +316,7 @@ def raw_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
directories and the local one survived. Same shape as Gitea #8, closed the
|
directories and the local one survived. Same shape as Gitea #8, closed the
|
||||||
same way - in the fixture, not in the one test that happened to trip.
|
same way - in the fixture, not in the one test that happened to trip.
|
||||||
"""
|
"""
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
raw = tmp_path / "raw"
|
raw = tmp_path / "raw"
|
||||||
(raw / "notes").mkdir(parents=True)
|
(raw / "notes").mkdir(parents=True)
|
||||||
@@ -286,7 +343,7 @@ def kb_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
"no collection" for every fixture page, which left `unauthorised_labels`
|
"no collection" for every fixture page, which left `unauthorised_labels`
|
||||||
with no working test at all (Gitea #44).
|
with no working test at all (Gitea #44).
|
||||||
"""
|
"""
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
kb = tmp_path / "kb"
|
kb = tmp_path / "kb"
|
||||||
for sub in ("entities/projects", "entities/systems", "entities/tools",
|
for sub in ("entities/projects", "entities/systems", "entities/tools",
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from chemenu import config
|
|||||||
from chemenu.api import Corpus
|
from chemenu.api import Corpus
|
||||||
from chemenu.errors import ChemenuError, ValidationError
|
from chemenu.errors import ChemenuError, ValidationError
|
||||||
from chemenu.types_core import UnknownType
|
from chemenu.types_core import UnknownType
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@@ -129,7 +130,7 @@ def test_derived_paths_follow_the_root_instead_of_lagging_behind(foreign_corpus,
|
|||||||
"""The failure that made the old shape worse than the limitation: `ROOT`
|
"""The failure that made the old shape worse than the limitation: `ROOT`
|
||||||
moved and `KB_DIR` did not, so a caller believed it was working on the
|
moved and `KB_DIR` did not, so a caller believed it was working on the
|
||||||
target tree while reading this one."""
|
target tree while reading this one."""
|
||||||
monkeypatch.setattr(config, "ROOT", foreign_corpus)
|
set_config_path(monkeypatch, "ROOT", foreign_corpus)
|
||||||
assert config.KB_DIR == foreign_corpus / "kb"
|
assert config.KB_DIR == foreign_corpus / "kb"
|
||||||
assert config.RAW_DIR == foreign_corpus / "raw"
|
assert config.RAW_DIR == foreign_corpus / "raw"
|
||||||
assert config.INDEX_FILE == foreign_corpus / "kb" / "index.md"
|
assert config.INDEX_FILE == foreign_corpus / "kb" / "index.md"
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from chemenu import backup, config, config_shapes, settings
|
|||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
from chemenu.commands import doctor
|
from chemenu.commands import doctor
|
||||||
from chemenu.commands.git_publish import publish_command
|
from chemenu.commands.git_publish import publish_command
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -54,7 +55,7 @@ def instance(tmp_path, monkeypatch):
|
|||||||
_git(root, "commit", "-m", "init")
|
_git(root, "commit", "-m", "init")
|
||||||
synced = tmp_path / "OneDrive - Example"
|
synced = tmp_path / "OneDrive - Example"
|
||||||
synced.mkdir()
|
synced.mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setenv("WIKITOOL_SESSION_ID", "test-session")
|
monkeypatch.setenv("WIKITOOL_SESSION_ID", "test-session")
|
||||||
return root
|
return root
|
||||||
|
|
||||||
@@ -478,7 +479,7 @@ def test_sync_folder_warns_under_cloud_storage(doctor_instance, tmp_path, monkey
|
|||||||
moved = cloud / "OneDrive-Example" / "instance"
|
moved = cloud / "OneDrive-Example" / "instance"
|
||||||
moved.parent.mkdir()
|
moved.parent.mkdir()
|
||||||
doctor_instance.rename(moved)
|
doctor_instance.rename(moved)
|
||||||
monkeypatch.setattr(config, "ROOT", moved)
|
set_config_path(monkeypatch, "ROOT", moved)
|
||||||
assert _check("sync-folder").status == "WARN"
|
assert _check("sync-folder").status == "WARN"
|
||||||
|
|
||||||
|
|
||||||
@@ -488,7 +489,7 @@ def test_sync_folder_sees_through_a_symlink(doctor_instance, tmp_path, monkeypat
|
|||||||
real = synced / "instance"
|
real = synced / "instance"
|
||||||
doctor_instance.rename(real)
|
doctor_instance.rename(real)
|
||||||
(tmp_path / "via-link").symlink_to(real)
|
(tmp_path / "via-link").symlink_to(real)
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path / "via-link")
|
set_config_path(monkeypatch, "ROOT", tmp_path / "via-link")
|
||||||
monkeypatch.setenv("OneDrive", str(synced))
|
monkeypatch.setenv("OneDrive", str(synced))
|
||||||
assert _check("sync-folder").status == "WARN"
|
assert _check("sync-folder").status == "WARN"
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from chemenu.commands.cite_cmd import sync_page, upsert_citation
|
|||||||
from chemenu.frontmatter_io import read_page
|
from chemenu.frontmatter_io import read_page
|
||||||
from chemenu.kb_scan import load_kb_pages
|
from chemenu.kb_scan import load_kb_pages
|
||||||
from chemenu.provenance import cite_id
|
from chemenu.provenance import cite_id
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -46,8 +47,8 @@ def test_cite_add_command_writes_definition_and_prints_marker(kb_dir, raw_dir, m
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
|
|
||||||
result = runner.invoke(app, ["cite", "add", "--page", "Modbus", "--source", "Source - Aurora"])
|
result = runner.invoke(app, ["cite", "add", "--page", "Modbus", "--source", "Source - Aurora"])
|
||||||
assert result.exit_code == 0, result.output
|
assert result.exit_code == 0, result.output
|
||||||
@@ -63,8 +64,8 @@ def test_cite_add_rejects_unknown_source(kb_dir, raw_dir, monkeypatch):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
|
|
||||||
result = runner.invoke(app, ["cite", "add", "--page", "Modbus", "--source", "Source - Nope"])
|
result = runner.invoke(app, ["cite", "add", "--page", "Modbus", "--source", "Source - Nope"])
|
||||||
assert result.exit_code != 0
|
assert result.exit_code != 0
|
||||||
@@ -74,7 +75,7 @@ def test_cite_id_command_prints_deterministic_id(raw_dir, monkeypatch):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
|
|
||||||
result = runner.invoke(app, ["cite", "id", "--title", "Source - Almanac Architecture", "--file", "storage-model.md"])
|
result = runner.invoke(app, ["cite", "id", "--title", "Source - Almanac Architecture", "--file", "storage-model.md"])
|
||||||
assert result.exit_code == 0, result.output
|
assert result.exit_code == 0, result.output
|
||||||
@@ -187,8 +188,8 @@ def test_cite_sync_command_over_kb(kb_dir, raw_dir, monkeypatch):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
|
|
||||||
add_result = runner.invoke(app, ["cite", "add", "--page", "Modbus", "--source", "Source - Aurora"])
|
add_result = runner.invoke(app, ["cite", "add", "--page", "Modbus", "--source", "Source - Aurora"])
|
||||||
assert add_result.exit_code == 0, add_result.output
|
assert add_result.exit_code == 0, add_result.output
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import typer
|
|||||||
from chemenu import collect, config, upload
|
from chemenu import collect, config, upload
|
||||||
from chemenu.errors import ValidationError
|
from chemenu.errors import ValidationError
|
||||||
from chemenu.commands.upload_cmd import upload_collect_command, upload_list_command
|
from chemenu.commands.upload_cmd import upload_collect_command, upload_list_command
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
OLD = time.time() - 3600
|
OLD = time.time() - 3600
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ def root(tmp_path, monkeypatch):
|
|||||||
instance = tmp_path / "instance"
|
instance = tmp_path / "instance"
|
||||||
instance.mkdir()
|
instance.mkdir()
|
||||||
(instance / "incoming").mkdir()
|
(instance / "incoming").mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", instance)
|
set_config_path(monkeypatch, "ROOT", instance)
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ from chemenu.errors import ValidationError
|
|||||||
from chemenu.tasks import caldav, superproductivity
|
from chemenu.tasks import caldav, superproductivity
|
||||||
from chemenu.tasks import config as tasks_config
|
from chemenu.tasks import config as tasks_config
|
||||||
from chemenu.telemetry import policy
|
from chemenu.telemetry import policy
|
||||||
from chemenu.tests.conftest import write_settings
|
from chemenu.tests.conftest import set_config_path, write_settings
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ CALDAV_OK = {"url": "https://dav.example/", "username": "u", "app_password": "pw
|
|||||||
def root(tmp_path, monkeypatch):
|
def root(tmp_path, monkeypatch):
|
||||||
tree = tmp_path / "instance"
|
tree = tmp_path / "instance"
|
||||||
tree.mkdir()
|
tree.mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", tree)
|
set_config_path(monkeypatch, "ROOT", tree)
|
||||||
return tree
|
return tree
|
||||||
|
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ def test_apply_fills_every_region_of_the_page_and_a_second_run_changes_nothing(t
|
|||||||
for name, _ in reference_doc.CONFIG_REGIONS:
|
for name, _ in reference_doc.CONFIG_REGIONS:
|
||||||
emptied = blocks.replace(emptied, name, blocks.open_marker(name) + "\n" + blocks.close_marker(name) + "\n")
|
emptied = blocks.replace(emptied, name, blocks.open_marker(name) + "\n" + blocks.close_marker(name) + "\n")
|
||||||
target.write_text(emptied, encoding="utf-8")
|
target.write_text(emptied, encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
_only_config_regions(monkeypatch)
|
_only_config_regions(monkeypatch)
|
||||||
|
|
||||||
result = runner.invoke(app, ["docs", "reference", "--apply"])
|
result = runner.invoke(app, ["docs", "reference", "--apply"])
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from pathlib import Path
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from chemenu import blocks, config, conventions, kb_collections
|
from chemenu import blocks, config, conventions, kb_collections
|
||||||
from chemenu.tests.conftest import use_shipped_type_specs
|
from chemenu.tests.conftest import set_config_path, use_shipped_type_specs
|
||||||
|
|
||||||
GERMAN = (
|
GERMAN = (
|
||||||
"---\n"
|
"---\n"
|
||||||
@@ -39,8 +39,8 @@ FRENCH = (
|
|||||||
def kb_root(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
def kb_root(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
||||||
kb = tmp_path / "kb"
|
kb = tmp_path / "kb"
|
||||||
kb.mkdir()
|
kb.mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb)
|
set_config_path(monkeypatch, "KB_DIR", kb)
|
||||||
# Which collections the stack requires are *derived* from where each
|
# Which collections the stack requires are *derived* from where each
|
||||||
# required type (`source`, `project`) writes, so these tests need the
|
# required type (`source`, `project`) writes, so these tests need the
|
||||||
# shipped `types/` reachable - a fixture tree without one derives an empty
|
# shipped `types/` reachable - a fixture tree without one derives an empty
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import pytest
|
|||||||
|
|
||||||
from chemenu import config, corpus_cache
|
from chemenu import config, corpus_cache
|
||||||
from chemenu.corpus_cache import CorpusCache
|
from chemenu.corpus_cache import CorpusCache
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
def _git(root: Path, *args: str) -> None:
|
def _git(root: Path, *args: str) -> None:
|
||||||
@@ -28,8 +29,8 @@ def repo(kb_dir: Path, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
_git(tmp_path, "config", "user.email", "fixture@example.com")
|
_git(tmp_path, "config", "user.email", "fixture@example.com")
|
||||||
_git(tmp_path, "add", "-A")
|
_git(tmp_path, "add", "-A")
|
||||||
_git(tmp_path, "commit", "-m", "fixture corpus")
|
_git(tmp_path, "commit", "-m", "fixture corpus")
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import typer
|
|||||||
|
|
||||||
from chemenu import config, toc, version as version_mod
|
from chemenu import config, toc, version as version_mod
|
||||||
from chemenu.commands import dist_cmd
|
from chemenu.commands import dist_cmd
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@@ -162,10 +163,10 @@ def repo(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
(root / "raw" / "notes").mkdir(parents=True, exist_ok=True)
|
(root / "raw" / "notes").mkdir(parents=True, exist_ok=True)
|
||||||
(root / "raw" / "notes" / "personal-note.md").write_text("private\n", encoding="utf-8")
|
(root / "raw" / "notes" / "personal-note.md").write_text("private\n", encoding="utf-8")
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb)
|
set_config_path(monkeypatch, "KB_DIR", kb)
|
||||||
monkeypatch.setattr(config, "INSTRUCTIONS_DIR", instructions)
|
set_config_path(monkeypatch, "INSTRUCTIONS_DIR", instructions)
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", types_dir)
|
set_config_path(monkeypatch, "TYPES_DIR", types_dir)
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import typer
|
|||||||
|
|
||||||
from chemenu import config, kb_state, version as version_mod
|
from chemenu import config, kb_state, version as version_mod
|
||||||
from chemenu.commands import dist_cmd
|
from chemenu.commands import dist_cmd
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
def _digest(text: str) -> str:
|
def _digest(text: str) -> str:
|
||||||
@@ -73,7 +74,7 @@ def instance(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
for the dirty-tree check)."""
|
for the dirty-tree check)."""
|
||||||
root = tmp_path / "instance"
|
root = tmp_path / "instance"
|
||||||
root.mkdir()
|
root.mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
|
|
||||||
(root / "VERSION").write_text("1.0.0\n", encoding="utf-8")
|
(root / "VERSION").write_text("1.0.0\n", encoding="utf-8")
|
||||||
(root / "AGENTS.md").write_text("core\n", encoding="utf-8")
|
(root / "AGENTS.md").write_text("core\n", encoding="utf-8")
|
||||||
@@ -900,7 +901,7 @@ def test_latest_yields_the_same_tree_as_the_archive_it_downloaded(instance, tmp_
|
|||||||
dist_cmd.run_upgrade(latest=True)
|
dist_cmd.run_upgrade(latest=True)
|
||||||
via_feed = {p.relative_to(instance): p.read_bytes() for p in instance.rglob("*") if p.is_file()}
|
via_feed = {p.relative_to(instance): p.read_bytes() for p in instance.rglob("*") if p.is_file()}
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", snapshot)
|
set_config_path(monkeypatch, "ROOT", snapshot)
|
||||||
dist_cmd.run_upgrade(served)
|
dist_cmd.run_upgrade(served)
|
||||||
via_archive = {p.relative_to(snapshot): p.read_bytes() for p in snapshot.rglob("*") if p.is_file()}
|
via_archive = {p.relative_to(snapshot): p.read_bytes() for p in snapshot.rglob("*") if p.is_file()}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import typer
|
|||||||
from chemenu import cli_contract, config, type_resolver
|
from chemenu import cli_contract, config, type_resolver
|
||||||
from chemenu.commands import dist_cmd, docs_verify
|
from chemenu.commands import dist_cmd, docs_verify
|
||||||
from chemenu.type_resolver import TypeResolver
|
from chemenu.type_resolver import TypeResolver
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
def test_every_registered_command_has_a_contract_record():
|
def test_every_registered_command_has_a_contract_record():
|
||||||
@@ -57,6 +58,20 @@ def _fixture_record(path: str) -> cli_contract.CommandRecord:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _built_command(callback):
|
||||||
|
"""`callback` as the command object the real check walks.
|
||||||
|
|
||||||
|
Built the way `docs_verify._leaf_click_commands()` builds the real tree -
|
||||||
|
a Typer app through `typer.main.get_command` - rather than from `click`
|
||||||
|
classes directly: typer no longer depends on the `click` package (it ships
|
||||||
|
its own fork as `typer._click`), and its option classes change their
|
||||||
|
constructor between minor versions, so only this public path stays put.
|
||||||
|
"""
|
||||||
|
app = typer.Typer(add_completion=False)
|
||||||
|
app.command(name="frobnicate")(callback)
|
||||||
|
return typer.main.get_command(app)
|
||||||
|
|
||||||
|
|
||||||
def test_commands_region_matches_the_generated_form(tmp_path, monkeypatch):
|
def test_commands_region_matches_the_generated_form(tmp_path, monkeypatch):
|
||||||
"""Regression guard for the drift this check exists to catch: a region
|
"""Regression guard for the drift this check exists to catch: a region
|
||||||
hand-edited (or simply left stale after a record changed) must fail, the
|
hand-edited (or simply left stale after a record changed) must fail, the
|
||||||
@@ -127,14 +142,16 @@ def test_every_registered_commands_flags_are_documented():
|
|||||||
|
|
||||||
|
|
||||||
def test_a_flag_the_synopsis_forgot_is_reported(monkeypatch):
|
def test_a_flag_the_synopsis_forgot_is_reported(monkeypatch):
|
||||||
import click
|
|
||||||
|
|
||||||
rec = _fixture_record("frobnicate")
|
rec = _fixture_record("frobnicate")
|
||||||
monkeypatch.setattr(cli_contract, "get", lambda path: rec if path == "frobnicate" else None)
|
monkeypatch.setattr(cli_contract, "get", lambda path: rec if path == "frobnicate" else None)
|
||||||
|
|
||||||
param = click.Option(["--flag"])
|
def frobnicate(
|
||||||
param2 = click.Option(["--forgotten"])
|
flag: str = typer.Option(None, "--flag"),
|
||||||
command = click.Command("frobnicate", params=[param, param2])
|
forgotten: str = typer.Option(None, "--forgotten"),
|
||||||
|
):
|
||||||
|
pass
|
||||||
|
|
||||||
|
command = _built_command(frobnicate)
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)]
|
docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)]
|
||||||
)
|
)
|
||||||
@@ -143,8 +160,6 @@ def test_a_flag_the_synopsis_forgot_is_reported(monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_a_phantom_synopsis_flag_is_reported(monkeypatch):
|
def test_a_phantom_synopsis_flag_is_reported(monkeypatch):
|
||||||
import click
|
|
||||||
|
|
||||||
rec = cli_contract.CommandRecord(
|
rec = cli_contract.CommandRecord(
|
||||||
path="frobnicate",
|
path="frobnicate",
|
||||||
summary="Does a thing.",
|
summary="Does a thing.",
|
||||||
@@ -153,8 +168,10 @@ def test_a_phantom_synopsis_flag_is_reported(monkeypatch):
|
|||||||
notes=("Does a thing.",),
|
notes=("Does a thing.",),
|
||||||
failures=(),
|
failures=(),
|
||||||
)
|
)
|
||||||
param = click.Option(["--flag"])
|
def frobnicate(flag: str = typer.Option(None, "--flag")):
|
||||||
command = click.Command("frobnicate", params=[param])
|
pass
|
||||||
|
|
||||||
|
command = _built_command(frobnicate)
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)]
|
docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)]
|
||||||
)
|
)
|
||||||
@@ -164,12 +181,15 @@ def test_a_phantom_synopsis_flag_is_reported(monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_a_hidden_flag_need_not_be_documented(monkeypatch):
|
def test_a_hidden_flag_need_not_be_documented(monkeypatch):
|
||||||
import click
|
|
||||||
|
|
||||||
rec = _fixture_record("frobnicate")
|
rec = _fixture_record("frobnicate")
|
||||||
param = click.Option(["--flag"])
|
|
||||||
hidden = click.Option(["--secret"], hidden=True)
|
def frobnicate(
|
||||||
command = click.Command("frobnicate", params=[param, hidden])
|
flag: str = typer.Option(None, "--flag"),
|
||||||
|
secret: str = typer.Option(None, "--secret", hidden=True),
|
||||||
|
):
|
||||||
|
pass
|
||||||
|
|
||||||
|
command = _built_command(frobnicate)
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)]
|
docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)]
|
||||||
)
|
)
|
||||||
@@ -181,8 +201,6 @@ def test_a_boolean_flag_pair_is_satisfied_by_either_spelling(monkeypatch):
|
|||||||
"""`--push`/`--no-push`: documenting only the negative spelling (the
|
"""`--push`/`--no-push`: documenting only the negative spelling (the
|
||||||
existing SYNOPSIS convention `publish` used before this check existed)
|
existing SYNOPSIS convention `publish` used before this check existed)
|
||||||
must not be reported as an undocumented `--push`."""
|
must not be reported as an undocumented `--push`."""
|
||||||
import click
|
|
||||||
|
|
||||||
rec = cli_contract.CommandRecord(
|
rec = cli_contract.CommandRecord(
|
||||||
path="frobnicate",
|
path="frobnicate",
|
||||||
summary="Does a thing.",
|
summary="Does a thing.",
|
||||||
@@ -191,8 +209,10 @@ def test_a_boolean_flag_pair_is_satisfied_by_either_spelling(monkeypatch):
|
|||||||
notes=("Does a thing.",),
|
notes=("Does a thing.",),
|
||||||
failures=(),
|
failures=(),
|
||||||
)
|
)
|
||||||
param = click.Option(["--push/--no-push"], default=True)
|
def frobnicate(push: bool = typer.Option(True, "--push/--no-push")):
|
||||||
command = click.Command("frobnicate", params=[param])
|
pass
|
||||||
|
|
||||||
|
command = _built_command(frobnicate)
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)]
|
docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)]
|
||||||
)
|
)
|
||||||
@@ -208,31 +228,31 @@ def test_no_registered_commands_help_cites_an_issue_number():
|
|||||||
|
|
||||||
|
|
||||||
def test_an_issue_number_above_the_form_feed_is_reported(monkeypatch):
|
def test_an_issue_number_above_the_form_feed_is_reported(monkeypatch):
|
||||||
import click
|
|
||||||
|
|
||||||
def frobnicate():
|
def frobnicate():
|
||||||
"""One sentence (Gitea #66)."""
|
"""One sentence (Gitea #66)."""
|
||||||
|
|
||||||
command = click.Command("frobnicate", callback=frobnicate, help=frobnicate.__doc__)
|
command = _built_command(frobnicate)
|
||||||
monkeypatch.setattr(docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)])
|
monkeypatch.setattr(docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)])
|
||||||
issues = docs_verify.check_no_issue_references_in_help()
|
issues = docs_verify.check_no_issue_references_in_help()
|
||||||
assert any("#66" in issue and "frobnicate" in issue for issue in issues)
|
assert any("#66" in issue and "frobnicate" in issue for issue in issues)
|
||||||
|
|
||||||
|
|
||||||
def test_an_issue_number_below_the_form_feed_is_not_reported(monkeypatch):
|
def test_an_issue_number_below_the_form_feed_is_not_reported(monkeypatch):
|
||||||
import click
|
def frobnicate():
|
||||||
|
"""One sentence.
|
||||||
|
\f
|
||||||
|
Maintenance text citing Gitea #66, never rendered."""
|
||||||
|
|
||||||
help_text = "One sentence.\n\f\nMaintenance text citing Gitea #66, never rendered."
|
command = _built_command(frobnicate)
|
||||||
command = click.Command("frobnicate", help=help_text)
|
|
||||||
monkeypatch.setattr(docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)])
|
monkeypatch.setattr(docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)])
|
||||||
assert docs_verify.check_no_issue_references_in_help() == []
|
assert docs_verify.check_no_issue_references_in_help() == []
|
||||||
|
|
||||||
|
|
||||||
def test_an_issue_number_in_an_options_help_text_is_reported(monkeypatch):
|
def test_an_issue_number_in_an_options_help_text_is_reported(monkeypatch):
|
||||||
import click
|
def frobnicate(flag: str = typer.Option(None, "--flag", help="Do the thing (Gitea #66).")):
|
||||||
|
pass
|
||||||
|
|
||||||
param = click.Option(["--flag"], help="Do the thing (Gitea #66).")
|
command = _built_command(frobnicate)
|
||||||
command = click.Command("frobnicate", params=[param])
|
|
||||||
monkeypatch.setattr(docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)])
|
monkeypatch.setattr(docs_verify, "_leaf_click_commands", lambda: [("frobnicate", command)])
|
||||||
issues = docs_verify.check_no_issue_references_in_help()
|
issues = docs_verify.check_no_issue_references_in_help()
|
||||||
assert any("#66" in issue and "--flag" in issue for issue in issues)
|
assert any("#66" in issue and "--flag" in issue for issue in issues)
|
||||||
@@ -271,7 +291,7 @@ def test_stage_readmes_are_checked_too(tmp_path, monkeypatch):
|
|||||||
(root / "tools" / "README.md").write_text(
|
(root / "tools" / "README.md").write_text(
|
||||||
"| Command | Purpose |\n| `publish` | pushes |\n", encoding="utf-8"
|
"| Command | Purpose |\n| `publish` | pushes |\n", encoding="utf-8"
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(docs_verify.config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setattr(docs_verify, "ROOT_README", root / "README.md")
|
monkeypatch.setattr(docs_verify, "ROOT_README", root / "README.md")
|
||||||
issues = docs_verify.check_readmes_have_no_command_table()
|
issues = docs_verify.check_readmes_have_no_command_table()
|
||||||
assert any("`publish`" in issue for issue in issues)
|
assert any("`publish`" in issue for issue in issues)
|
||||||
@@ -284,7 +304,7 @@ def test_install_md_is_checked_too(tmp_path, monkeypatch):
|
|||||||
(root / "INSTALL.md").write_text(
|
(root / "INSTALL.md").write_text(
|
||||||
"| Command | Purpose |\n| `doctor` | checks things |\n", encoding="utf-8"
|
"| Command | Purpose |\n| `doctor` | checks things |\n", encoding="utf-8"
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(docs_verify.config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setattr(docs_verify, "ROOT_README", root / "README.md") # doesn't exist here
|
monkeypatch.setattr(docs_verify, "ROOT_README", root / "README.md") # doesn't exist here
|
||||||
issues = docs_verify.check_readmes_have_no_command_table()
|
issues = docs_verify.check_readmes_have_no_command_table()
|
||||||
assert any("`doctor`" in issue for issue in issues)
|
assert any("`doctor`" in issue for issue in issues)
|
||||||
@@ -299,7 +319,7 @@ def test_the_developer_guide_is_checked_too(tmp_path, monkeypatch):
|
|||||||
(root / "docs" / "dev" / "development.md").write_text(
|
(root / "docs" / "dev" / "development.md").write_text(
|
||||||
"| Command | Purpose |\n| `docs verify` | checks docs |\n", encoding="utf-8"
|
"| Command | Purpose |\n| `docs verify` | checks docs |\n", encoding="utf-8"
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(docs_verify.config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setattr(docs_verify, "ROOT_README", root / "README.md") # doesn't exist here
|
monkeypatch.setattr(docs_verify, "ROOT_README", root / "README.md") # doesn't exist here
|
||||||
issues = docs_verify.check_readmes_have_no_command_table()
|
issues = docs_verify.check_readmes_have_no_command_table()
|
||||||
assert any("`docs verify`" in issue for issue in issues)
|
assert any("`docs verify`" in issue for issue in issues)
|
||||||
@@ -310,7 +330,7 @@ def test_an_absent_listed_doc_is_skipped_not_reported(tmp_path, monkeypatch):
|
|||||||
it must stay inert where the file does not exist rather than failing a tree
|
it must stay inert where the file does not exist rather than failing a tree
|
||||||
that is correct."""
|
that is correct."""
|
||||||
root = tmp_path
|
root = tmp_path
|
||||||
monkeypatch.setattr(docs_verify.config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setattr(docs_verify, "ROOT_README", root / "README.md")
|
monkeypatch.setattr(docs_verify, "ROOT_README", root / "README.md")
|
||||||
assert docs_verify.check_readmes_have_no_command_table() == []
|
assert docs_verify.check_readmes_have_no_command_table() == []
|
||||||
|
|
||||||
@@ -352,8 +372,8 @@ def test_an_unknown_type_spec_field_is_reported(tmp_path, monkeypatch):
|
|||||||
"---\n",
|
"---\n",
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", types_dir)
|
set_config_path(monkeypatch, "TYPES_DIR", types_dir)
|
||||||
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=tmp_path))
|
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=tmp_path))
|
||||||
|
|
||||||
issues = docs_verify.check_type_spec_frontmatter()
|
issues = docs_verify.check_type_spec_frontmatter()
|
||||||
@@ -378,8 +398,8 @@ def _stack_required_type_tree(tmp_path, monkeypatch, project_md: str = "", proje
|
|||||||
(types_dir / "project.md").write_text(project_md, encoding="utf-8")
|
(types_dir / "project.md").write_text(project_md, encoding="utf-8")
|
||||||
if project_schema:
|
if project_schema:
|
||||||
(types_dir / "project.schema.yaml").write_text(project_schema, encoding="utf-8")
|
(types_dir / "project.schema.yaml").write_text(project_schema, encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", types_dir)
|
set_config_path(monkeypatch, "TYPES_DIR", types_dir)
|
||||||
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=tmp_path))
|
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=tmp_path))
|
||||||
|
|
||||||
|
|
||||||
@@ -495,7 +515,7 @@ def test_this_repos_version_and_changelog_agree():
|
|||||||
def _versioned_tree(tmp_path, monkeypatch, version: str, changes: str):
|
def _versioned_tree(tmp_path, monkeypatch, version: str, changes: str):
|
||||||
(tmp_path / "VERSION").write_text(version, encoding="utf-8")
|
(tmp_path / "VERSION").write_text(version, encoding="utf-8")
|
||||||
(tmp_path / "CHANGES.md").write_text(changes, encoding="utf-8")
|
(tmp_path / "CHANGES.md").write_text(changes, encoding="utf-8")
|
||||||
monkeypatch.setattr(docs_verify.config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
|
|
||||||
|
|
||||||
def test_a_bump_with_no_changelog_entry_is_reported(tmp_path, monkeypatch):
|
def test_a_bump_with_no_changelog_entry_is_reported(tmp_path, monkeypatch):
|
||||||
@@ -518,7 +538,7 @@ def test_a_changelog_with_no_versioned_entry_is_accepted(tmp_path, monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_a_missing_or_malformed_version_is_reported(tmp_path, monkeypatch):
|
def test_a_missing_or_malformed_version_is_reported(tmp_path, monkeypatch):
|
||||||
monkeypatch.setattr(docs_verify.config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
assert any("VERSION" in issue for issue in docs_verify.check_version_changelog())
|
assert any("VERSION" in issue for issue in docs_verify.check_version_changelog())
|
||||||
_versioned_tree(tmp_path, monkeypatch, "not-a-version\n", "# Changelog\n")
|
_versioned_tree(tmp_path, monkeypatch, "not-a-version\n", "# Changelog\n")
|
||||||
assert any("semantic version" in issue for issue in docs_verify.check_version_changelog())
|
assert any("semantic version" in issue for issue in docs_verify.check_version_changelog())
|
||||||
@@ -544,8 +564,8 @@ def _boundary_tree(tmp_path, monkeypatch, current: str, previous: str, marker: s
|
|||||||
)
|
)
|
||||||
instructions = tmp_path / "instructions"
|
instructions = tmp_path / "instructions"
|
||||||
(instructions / "migrations").mkdir(parents=True, exist_ok=True)
|
(instructions / "migrations").mkdir(parents=True, exist_ok=True)
|
||||||
monkeypatch.setattr(docs_verify.config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(docs_verify.config, "INSTRUCTIONS_DIR", instructions)
|
set_config_path(monkeypatch, "INSTRUCTIONS_DIR", instructions)
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|
||||||
|
|
||||||
@@ -801,7 +821,7 @@ def test_a_shipped_template_over_the_threshold_without_a_region_is_reported(tmp_
|
|||||||
returned nothing here."""
|
returned nothing here."""
|
||||||
from chemenu import config, toc as toc_mod
|
from chemenu import config, toc as toc_mod
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
(tmp_path / "kb").mkdir()
|
(tmp_path / "kb").mkdir()
|
||||||
long_body = "# Conventions\n\nIntro.\n" + "".join(
|
long_body = "# Conventions\n\nIntro.\n" + "".join(
|
||||||
f"\n## Section {i}\n\n" + "Body line.\n" * 12 for i in range(8)
|
f"\n## Section {i}\n\n" + "Body line.\n" * 12 for i in range(8)
|
||||||
@@ -917,7 +937,7 @@ def test_this_repos_docs_are_laid_out_in_areas():
|
|||||||
def _docs_tree(tmp_path, monkeypatch, files: tuple[str, ...]):
|
def _docs_tree(tmp_path, monkeypatch, files: tuple[str, ...]):
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
for relative in files:
|
for relative in files:
|
||||||
path = tmp_path / relative
|
path = tmp_path / relative
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
@@ -962,7 +982,7 @@ def test_verify_raises_when_a_docs_file_is_outside_every_area(monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def _agents_with_gates(tmp_path, monkeypatch, names: list[str], section: str = "## Gates") -> None:
|
def _agents_with_gates(tmp_path, monkeypatch, names: list[str], section: str = "## Gates") -> None:
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
entries = "".join(f"- **{name}.** Does something.\n" for name in names)
|
entries = "".join(f"- **{name}.** Does something.\n" for name in names)
|
||||||
(tmp_path / "AGENTS.md").write_text(
|
(tmp_path / "AGENTS.md").write_text(
|
||||||
f"# AGENTS\n\n{section}\n\nThese are enforced in code.\n\n{entries}\n"
|
f"# AGENTS\n\n{section}\n\nThese are enforced in code.\n\n{entries}\n"
|
||||||
@@ -1011,7 +1031,7 @@ def test_a_tree_with_no_gates_section_is_reported(tmp_path, monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_a_tree_with_no_agents_md_is_reported(tmp_path, monkeypatch):
|
def test_a_tree_with_no_agents_md_is_reported(tmp_path, monkeypatch):
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
issues = docs_verify.check_gates_list()
|
issues = docs_verify.check_gates_list()
|
||||||
assert len(issues) == 1 and "AGENTS.md is missing" in issues[0]
|
assert len(issues) == 1 and "AGENTS.md is missing" in issues[0]
|
||||||
|
|
||||||
@@ -1074,7 +1094,7 @@ def test_the_9_0_0_upgrade_breaks_an_old_conventions_link_until_the_migration_ra
|
|||||||
document = (
|
document = (
|
||||||
config.ROOT / "instructions" / "migrations" / "9.0.0-docs-diataxis.md"
|
config.ROOT / "instructions" / "migrations" / "9.0.0-docs-diataxis.md"
|
||||||
).read_text(encoding="utf-8")
|
).read_text(encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
(tmp_path / "kb").mkdir()
|
(tmp_path / "kb").mkdir()
|
||||||
conventions = tmp_path / "kb" / "CONVENTIONS.md"
|
conventions = tmp_path / "kb" / "CONVENTIONS.md"
|
||||||
conventions.write_text(
|
conventions.write_text(
|
||||||
@@ -1250,8 +1270,8 @@ def _subtype_tree(tmp_path, monkeypatch, files: dict):
|
|||||||
shutil.copytree(config.ROOT / "types", types_dir)
|
shutil.copytree(config.ROOT / "types", types_dir)
|
||||||
for name, text in files.items():
|
for name, text in files.items():
|
||||||
(types_dir / name).write_text(text, encoding="utf-8")
|
(types_dir / name).write_text(text, encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", types_dir)
|
set_config_path(monkeypatch, "TYPES_DIR", types_dir)
|
||||||
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=tmp_path))
|
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=tmp_path))
|
||||||
return docs_verify.check_subtype_templates()
|
return docs_verify.check_subtype_templates()
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import pytest
|
|||||||
|
|
||||||
from chemenu import config, conventions, prerequisites, toolpaths
|
from chemenu import config, conventions, prerequisites, toolpaths
|
||||||
from chemenu.commands import doctor, instructions_cmd
|
from chemenu.commands import doctor, instructions_cmd
|
||||||
from chemenu.tests.conftest import write_settings
|
from chemenu.tests.conftest import set_config_path, write_settings
|
||||||
|
|
||||||
|
|
||||||
def _git(root: Path, *args: str) -> None:
|
def _git(root: Path, *args: str) -> None:
|
||||||
@@ -72,14 +72,14 @@ def instance(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
"---\nname: wiki-demo\ndescription: Demo skill.\n---\n", encoding="utf-8"
|
"---\nname: wiki-demo\ndescription: Demo skill.\n---\n", encoding="utf-8"
|
||||||
)
|
)
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb)
|
set_config_path(monkeypatch, "KB_DIR", kb)
|
||||||
monkeypatch.setattr(config, "INDEX_FILE", kb / "index.md")
|
set_config_path(monkeypatch, "INDEX_FILE", kb / "index.md")
|
||||||
monkeypatch.setattr(config, "LOG_FILE", kb / "log.md")
|
set_config_path(monkeypatch, "LOG_FILE", kb / "log.md")
|
||||||
monkeypatch.setattr(config, "PROVENANCE_FILE", kb / "provenance.md")
|
set_config_path(monkeypatch, "PROVENANCE_FILE", kb / "provenance.md")
|
||||||
monkeypatch.setattr(config, "INSTRUCTIONS_DIR", instructions)
|
set_config_path(monkeypatch, "INSTRUCTIONS_DIR", instructions)
|
||||||
monkeypatch.setattr(config, "AGENTS_SKILLS_DIR", root / ".agents" / "skills")
|
set_config_path(monkeypatch, "AGENTS_SKILLS_DIR", root / ".agents" / "skills")
|
||||||
monkeypatch.setattr(config, "CLAUDE_SKILLS_DIR", root / ".claude" / "skills")
|
set_config_path(monkeypatch, "CLAUDE_SKILLS_DIR", root / ".claude" / "skills")
|
||||||
monkeypatch.setenv("WIKI_AUTHOR", "Fixture Author")
|
monkeypatch.setenv("WIKI_AUTHOR", "Fixture Author")
|
||||||
monkeypatch.delenv("WIKITOOL_SESSION_ID", raising=False)
|
monkeypatch.delenv("WIKITOOL_SESSION_ID", raising=False)
|
||||||
|
|
||||||
@@ -510,7 +510,7 @@ def test_no_author_fails(instance, monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_not_a_git_repo_fails(tmp_path, monkeypatch):
|
def test_not_a_git_repo_fails(tmp_path, monkeypatch):
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
checks = doctor.run_doctor()
|
checks = doctor.run_doctor()
|
||||||
assert _status(checks, "git-repo") == "FAIL"
|
assert _status(checks, "git-repo") == "FAIL"
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ from chemenu.search.registry import resolve
|
|||||||
from chemenu.search.service import load_pages_by_path, run_search
|
from chemenu.search.service import load_pages_by_path, run_search
|
||||||
from chemenu.search.types import SearchQuery
|
from chemenu.search.types import SearchQuery
|
||||||
from chemenu.type_resolver import resolver
|
from chemenu.type_resolver import resolver
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -153,7 +154,7 @@ def _commit_instance(root: Path, message: str = "instance change") -> None:
|
|||||||
def instance(kb_dir, monkeypatch):
|
def instance(kb_dir, monkeypatch):
|
||||||
root = kb_dir.parent
|
root = kb_dir.parent
|
||||||
shutil.copytree(config._PACKAGE_ROOT / "types", root / "types")
|
shutil.copytree(config._PACKAGE_ROOT / "types", root / "types")
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", root / "types")
|
set_config_path(monkeypatch, "TYPES_DIR", root / "types")
|
||||||
monkeypatch.setattr(resolver, "_repo_root", root)
|
monkeypatch.setattr(resolver, "_repo_root", root)
|
||||||
monkeypatch.setattr(repo_capture, "ALLOWED_SCHEMES", ("ssh", "https", "file"))
|
monkeypatch.setattr(repo_capture, "ALLOWED_SCHEMES", ("ssh", "https", "file"))
|
||||||
(root / "raw").mkdir(exist_ok=True)
|
(root / "raw").mkdir(exist_ok=True)
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ from chemenu.commands.git_publish import publish_command
|
|||||||
from chemenu.frontmatter_io import write_page
|
from chemenu.frontmatter_io import write_page
|
||||||
from chemenu.search.service import load_pages_by_path
|
from chemenu.search.service import load_pages_by_path
|
||||||
from chemenu.type_resolver import resolver
|
from chemenu.type_resolver import resolver
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -92,14 +93,14 @@ def instance(tmp_path, monkeypatch):
|
|||||||
"/incoming/*\n!/incoming/.gitkeep\n/.wikitool-local.json\n/quarantine/\n/reports/\n",
|
"/incoming/*\n!/incoming/.gitkeep\n/.wikitool-local.json\n/quarantine/\n/reports/\n",
|
||||||
encoding="utf-8")
|
encoding="utf-8")
|
||||||
shutil.copytree(config._PACKAGE_ROOT / "types", root / "types")
|
shutil.copytree(config._PACKAGE_ROOT / "types", root / "types")
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", root / "types")
|
set_config_path(monkeypatch, "TYPES_DIR", root / "types")
|
||||||
monkeypatch.setattr(resolver, "_repo_root", root)
|
monkeypatch.setattr(resolver, "_repo_root", root)
|
||||||
_page(root, "concepts/Alpha.md", ALPHA)
|
_page(root, "concepts/Alpha.md", ALPHA)
|
||||||
_page(root, "concepts/protocols/Beta.md", BETA)
|
_page(root, "concepts/protocols/Beta.md", BETA)
|
||||||
_page(root, "concepts/Gamma.md", "\n# Gamma\n\nPrivate.\n", tags=["private"])
|
_page(root, "concepts/Gamma.md", "\n# Gamma\n\nPrivate.\n", tags=["private"])
|
||||||
_commit(root, "init")
|
_commit(root, "init")
|
||||||
(tmp_path / "OneDrive - Example").mkdir()
|
(tmp_path / "OneDrive - Example").mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setenv("WIKITOOL_SESSION_ID", "test-session")
|
monkeypatch.setenv("WIKITOOL_SESSION_ID", "test-session")
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ def repo(tmp_path, monkeypatch):
|
|||||||
_git(root, "commit", "-m", "init")
|
_git(root, "commit", "-m", "init")
|
||||||
_git(root, "push", "-u", "origin", "main")
|
_git(root, "push", "-u", "origin", "main")
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setenv("WIKITOOL_SESSION_ID", "test-session")
|
monkeypatch.setenv("WIKITOOL_SESSION_ID", "test-session")
|
||||||
return root
|
return root
|
||||||
|
|
||||||
@@ -346,7 +346,7 @@ def fresh_instance(tmp_path, monkeypatch):
|
|||||||
(root / "kb").mkdir()
|
(root / "kb").mkdir()
|
||||||
(root / "README.md").write_text("fresh instance\n", encoding="utf-8")
|
(root / "README.md").write_text("fresh instance\n", encoding="utf-8")
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setenv("WIKITOOL_SESSION_ID", "test-session")
|
monkeypatch.setenv("WIKITOOL_SESSION_ID", "test-session")
|
||||||
return root
|
return root
|
||||||
|
|
||||||
@@ -1519,7 +1519,7 @@ from contextlib import contextmanager
|
|||||||
|
|
||||||
from chemenu.commands.log_append import format_log_entry, parse_log_entries
|
from chemenu.commands.log_append import format_log_entry, parse_log_entries
|
||||||
from chemenu.frontmatter_io import write_page
|
from chemenu.frontmatter_io import write_page
|
||||||
from chemenu.tests.conftest import use_shipped_type_specs
|
from chemenu.tests.conftest import set_config_path, use_shipped_type_specs
|
||||||
|
|
||||||
GENERATED_FILES = ("kb/index.md", "kb/log.md", "kb/provenance.md", "kb/concepts/INDEX.md")
|
GENERATED_FILES = ("kb/index.md", "kb/log.md", "kb/provenance.md", "kb/concepts/INDEX.md")
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,13 @@ from pathlib import Path
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.tests.conftest import _GIT_ENV, _WIKITOOL_ENV
|
from chemenu.tests import conftest
|
||||||
|
from chemenu.tests.conftest import (
|
||||||
|
_GIT_ENV,
|
||||||
|
_WIKITOOL_ENV,
|
||||||
|
bound_config_paths,
|
||||||
|
set_config_path,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_home_points_into_the_test_s_own_tmp_path(tmp_path: Path, hermetic_environment: Path):
|
def test_home_points_into_the_test_s_own_tmp_path(tmp_path: Path, hermetic_environment: Path):
|
||||||
@@ -55,7 +61,7 @@ def test_default_author_is_none_without_an_identity(tmp_path: Path,
|
|||||||
monkeypatch: pytest.MonkeyPatch):
|
monkeypatch: pytest.MonkeyPatch):
|
||||||
"""The branch that used to be untestable: no WIKI_AUTHOR, no git identity
|
"""The branch that used to be untestable: no WIKI_AUTHOR, no git identity
|
||||||
anywhere, so `new source` has nothing to stamp and must say so."""
|
anywhere, so `new source` has nothing to stamp and must say so."""
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
assert config.default_author() is None
|
assert config.default_author() is None
|
||||||
|
|
||||||
|
|
||||||
@@ -63,7 +69,7 @@ def test_default_author_reads_a_local_git_identity(tmp_path: Path,
|
|||||||
monkeypatch: pytest.MonkeyPatch):
|
monkeypatch: pytest.MonkeyPatch):
|
||||||
subprocess.run(["git", "init", "-q", "-b", "main"], cwd=tmp_path, check=True)
|
subprocess.run(["git", "init", "-q", "-b", "main"], cwd=tmp_path, check=True)
|
||||||
subprocess.run(["git", "config", "user.name", "Local Identity"], cwd=tmp_path, check=True)
|
subprocess.run(["git", "config", "user.name", "Local Identity"], cwd=tmp_path, check=True)
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
assert config.default_author() == "Local Identity"
|
assert config.default_author() == "Local Identity"
|
||||||
|
|
||||||
|
|
||||||
@@ -71,7 +77,7 @@ def test_wiki_author_overrides_the_git_identity(tmp_path: Path,
|
|||||||
monkeypatch: pytest.MonkeyPatch):
|
monkeypatch: pytest.MonkeyPatch):
|
||||||
subprocess.run(["git", "init", "-q", "-b", "main"], cwd=tmp_path, check=True)
|
subprocess.run(["git", "init", "-q", "-b", "main"], cwd=tmp_path, check=True)
|
||||||
subprocess.run(["git", "config", "user.name", "Local Identity"], cwd=tmp_path, check=True)
|
subprocess.run(["git", "config", "user.name", "Local Identity"], cwd=tmp_path, check=True)
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setenv("WIKI_AUTHOR", "Env Override")
|
monkeypatch.setenv("WIKI_AUTHOR", "Env Override")
|
||||||
assert config.default_author() == "Env Override"
|
assert config.default_author() == "Env Override"
|
||||||
|
|
||||||
@@ -94,3 +100,81 @@ def test_both_corpus_fixtures_keep_the_shipped_type_specs_reachable(kb_dir: Path
|
|||||||
"""Repointing `ROOT` moves `TYPES_DIR` with it, so the repoint has to be
|
"""Repointing `ROOT` moves `TYPES_DIR` with it, so the repoint has to be
|
||||||
paired with `use_shipped_type_specs()` or no page type resolves at all."""
|
paired with `use_shipped_type_specs()` or no page type resolves at all."""
|
||||||
assert (config.TYPES_DIR / "entity.md").is_file()
|
assert (config.TYPES_DIR / "entity.md").is_file()
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_repointed_root_is_taken_back_to_resolution(tmp_path: Path):
|
||||||
|
"""After the undo `ROOT` is bound exactly when it was before - here: not at
|
||||||
|
all - and resolves through `resolve_root()` again, carrying the derived
|
||||||
|
paths with it. Up to pytest 9.1, `monkeypatch.setattr` left the resolved
|
||||||
|
path behind as a real attribute instead."""
|
||||||
|
assert bound_config_paths() == []
|
||||||
|
with pytest.MonkeyPatch.context() as mp:
|
||||||
|
set_config_path(mp, "ROOT", tmp_path)
|
||||||
|
assert config.ROOT == tmp_path
|
||||||
|
assert config.KB_DIR == tmp_path / "kb"
|
||||||
|
assert bound_config_paths() == []
|
||||||
|
assert config.ROOT == config.resolve_root()
|
||||||
|
assert config.KB_DIR == config.resolve_root() / "kb"
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_undo_survives_hermetic_environment_resetting_first(tmp_path: Path):
|
||||||
|
"""The teardown order every test has: `hermetic_environment` calls
|
||||||
|
`config.reset()`, and only then does `monkeypatch` undo. From pytest 9.2
|
||||||
|
on, `monkeypatch.setattr`'s undo raises at exactly this point."""
|
||||||
|
mp = pytest.MonkeyPatch()
|
||||||
|
set_config_path(mp, "ROOT", tmp_path)
|
||||||
|
config.reset()
|
||||||
|
mp.undo()
|
||||||
|
assert bound_config_paths() == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_binding_that_was_there_before_is_restored(tmp_path: Path):
|
||||||
|
before = tmp_path / "before"
|
||||||
|
vars(config)["KB_DIR"] = before
|
||||||
|
try:
|
||||||
|
with pytest.MonkeyPatch.context() as mp:
|
||||||
|
set_config_path(mp, "KB_DIR", tmp_path / "during")
|
||||||
|
assert config.KB_DIR == tmp_path / "during"
|
||||||
|
assert vars(config)["KB_DIR"] == before
|
||||||
|
finally:
|
||||||
|
config.reset()
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_name_config_does_not_manage_is_refused(monkeypatch):
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
set_config_path(monkeypatch, "ENV_ROOT", "elsewhere")
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_teardown_guard_fails_a_test_that_leaves_a_path_bound(request, tmp_path: Path):
|
||||||
|
"""What makes a fallback to `monkeypatch.setattr(config, "ROOT", ...)`
|
||||||
|
visible under every pytest version: up to 9.1 its undo leaves `ROOT` bound,
|
||||||
|
and this guard fails the test; from 9.2 the undo itself raises."""
|
||||||
|
guard = conftest.pytest_runtest_teardown(request.node, None)
|
||||||
|
next(guard)
|
||||||
|
vars(config)["ROOT"] = tmp_path
|
||||||
|
with pytest.raises(AssertionError, match="left chemenu.config path"):
|
||||||
|
guard.send(None)
|
||||||
|
assert bound_config_paths() == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_teardown_guard_passes_a_test_that_left_nothing_bound(request):
|
||||||
|
guard = conftest.pytest_runtest_teardown(request.node, None)
|
||||||
|
next(guard)
|
||||||
|
with pytest.raises(StopIteration):
|
||||||
|
guard.send(None)
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_fallback_to_monkeypatch_setattr_does_not_go_unnoticed(tmp_path: Path):
|
||||||
|
"""The invariant's other side: the call this suite no longer makes either
|
||||||
|
raises on undo or leaves the binding for the guard - never neither."""
|
||||||
|
mp = pytest.MonkeyPatch()
|
||||||
|
mp.setattr(config, "ROOT", tmp_path)
|
||||||
|
config.reset()
|
||||||
|
try:
|
||||||
|
mp.undo()
|
||||||
|
except AttributeError:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
assert bound_config_paths() == ["ROOT"]
|
||||||
|
finally:
|
||||||
|
config.reset()
|
||||||
@@ -2,6 +2,7 @@ from typer.testing import CliRunner
|
|||||||
|
|
||||||
from chemenu import config, install_doc, prerequisites
|
from chemenu import config, install_doc, prerequisites
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ SETUP = """# Set up
|
|||||||
|
|
||||||
|
|
||||||
def _tree(tmp_path, monkeypatch, install=CURRENT, setup=SETUP, manifest=MANIFEST):
|
def _tree(tmp_path, monkeypatch, install=CURRENT, setup=SETUP, manifest=MANIFEST):
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(prerequisites, "load_manifest", lambda path=None: manifest)
|
monkeypatch.setattr(prerequisites, "load_manifest", lambda path=None: manifest)
|
||||||
(tmp_path / "instructions").mkdir()
|
(tmp_path / "instructions").mkdir()
|
||||||
(tmp_path / "INSTALL.md").write_text(install, encoding="utf-8")
|
(tmp_path / "INSTALL.md").write_text(install, encoding="utf-8")
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import pytest
|
|||||||
import typer
|
import typer
|
||||||
|
|
||||||
from chemenu import config, conventions
|
from chemenu import config, conventions
|
||||||
from chemenu.tests.conftest import use_shipped_type_specs
|
from chemenu.tests.conftest import set_config_path, use_shipped_type_specs
|
||||||
from chemenu.commands import instructions_cmd
|
from chemenu.commands import instructions_cmd
|
||||||
|
|
||||||
|
|
||||||
@@ -33,11 +33,11 @@ def layer(tmp_path: Path, monkeypatch):
|
|||||||
(root / "AGENTS.md").write_text("# AGENTS\n", encoding="utf-8")
|
(root / "AGENTS.md").write_text("# AGENTS\n", encoding="utf-8")
|
||||||
(root / "kb").mkdir()
|
(root / "kb").mkdir()
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setattr(config, "KB_DIR", root / "kb")
|
set_config_path(monkeypatch, "KB_DIR", root / "kb")
|
||||||
monkeypatch.setattr(config, "INSTRUCTIONS_DIR", instructions)
|
set_config_path(monkeypatch, "INSTRUCTIONS_DIR", instructions)
|
||||||
monkeypatch.setattr(config, "AGENTS_SKILLS_DIR", root / ".agents" / "skills")
|
set_config_path(monkeypatch, "AGENTS_SKILLS_DIR", root / ".agents" / "skills")
|
||||||
monkeypatch.setattr(config, "CLAUDE_SKILLS_DIR", root / ".claude" / "skills")
|
set_config_path(monkeypatch, "CLAUDE_SKILLS_DIR", root / ".claude" / "skills")
|
||||||
# `verify` resolves each instruction's `type: types/instruction.md`, and the
|
# `verify` resolves each instruction's `type: types/instruction.md`, and the
|
||||||
# resolver's root follows `ROOT` now - so the shipped specs have to be named
|
# resolver's root follows `ROOT` now - so the shipped specs have to be named
|
||||||
# rather than inherited. See `use_shipped_type_specs`.
|
# rather than inherited. See `use_shipped_type_specs`.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import pytest
|
|||||||
|
|
||||||
from chemenu import config, kb_collections, type_resolver
|
from chemenu import config, kb_collections, type_resolver
|
||||||
from chemenu.type_resolver import TypeResolver
|
from chemenu.type_resolver import TypeResolver
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@@ -17,8 +18,8 @@ def repo(tmp_path: Path, monkeypatch) -> Path:
|
|||||||
(kb / "README.md").write_text("# KB Routing\n", encoding="utf-8")
|
(kb / "README.md").write_text("# KB Routing\n", encoding="utf-8")
|
||||||
(tmp_path / "raw").mkdir()
|
(tmp_path / "raw").mkdir()
|
||||||
(tmp_path / "types").mkdir()
|
(tmp_path / "types").mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb)
|
set_config_path(monkeypatch, "KB_DIR", kb)
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|
||||||
|
|
||||||
@@ -89,7 +90,7 @@ def test_stack_required_collections_includes_gtd_once_project_type_exists(repo,
|
|||||||
"---\n",
|
"---\n",
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", types_dir)
|
set_config_path(monkeypatch, "TYPES_DIR", types_dir)
|
||||||
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=repo))
|
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=repo))
|
||||||
assert "gtd" in kb_collections.stack_required_collections()
|
assert "gtd" in kb_collections.stack_required_collections()
|
||||||
|
|
||||||
@@ -97,6 +98,6 @@ def test_stack_required_collections_includes_gtd_once_project_type_exists(repo,
|
|||||||
def test_stack_required_collections_omits_a_type_with_no_type_spec(repo, monkeypatch):
|
def test_stack_required_collections_omits_a_type_with_no_type_spec(repo, monkeypatch):
|
||||||
"""No `project.md` at all - the required-types derivation must tolerate a
|
"""No `project.md` at all - the required-types derivation must tolerate a
|
||||||
missing type rather than raising, so a corpus mid-adoption still lints."""
|
missing type rather than raising, so a corpus mid-adoption still lints."""
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", repo / "types")
|
set_config_path(monkeypatch, "TYPES_DIR", repo / "types")
|
||||||
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=repo))
|
monkeypatch.setattr(type_resolver, "resolver", TypeResolver(repo_root=repo))
|
||||||
assert "gtd" not in kb_collections.stack_required_collections()
|
assert "gtd" not in kb_collections.stack_required_collections()
|
||||||
@@ -21,6 +21,7 @@ from chemenu import config, config_shapes, legacy_settings, settings, upload
|
|||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
from chemenu.tasks import caldav, config as tasks_config, superproductivity
|
from chemenu.tasks import caldav, config as tasks_config, superproductivity
|
||||||
from chemenu.telemetry import policy
|
from chemenu.telemetry import policy
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -129,7 +130,7 @@ def checkout(tmp_path, monkeypatch):
|
|||||||
"""A git checkout under `tmp_path/work`, with the secrets file kept outside it."""
|
"""A git checkout under `tmp_path/work`, with the secrets file kept outside it."""
|
||||||
root = tmp_path / "work"
|
root = tmp_path / "work"
|
||||||
root.mkdir()
|
root.mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setenv("XDG_CONFIG_HOME", str(tmp_path / "xdg"))
|
monkeypatch.setenv("XDG_CONFIG_HOME", str(tmp_path / "xdg"))
|
||||||
subprocess.run(["git", "init", "-b", "main"], cwd=root, check=True, capture_output=True)
|
subprocess.run(["git", "init", "-b", "main"], cwd=root, check=True, capture_output=True)
|
||||||
subprocess.run(["git", "config", "user.email", "a@example.net"], cwd=root, check=True)
|
subprocess.run(["git", "config", "user.email", "a@example.net"], cwd=root, check=True)
|
||||||
@@ -345,7 +346,7 @@ def test_a_migrated_setting_that_is_already_there_with_the_same_value_is_not_a_c
|
|||||||
])
|
])
|
||||||
def test_a_leftover_makes_the_command_that_needs_the_setting_exit_42(checkout, monkeypatch, args, name):
|
def test_a_leftover_makes_the_command_that_needs_the_setting_exit_42(checkout, monkeypatch, args, name):
|
||||||
(checkout / "kb").mkdir()
|
(checkout / "kb").mkdir()
|
||||||
monkeypatch.setattr(config, "KB_DIR", checkout / "kb")
|
set_config_path(monkeypatch, "KB_DIR", checkout / "kb")
|
||||||
(checkout / name).write_text("{}", encoding="utf-8")
|
(checkout / name).write_text("{}", encoding="utf-8")
|
||||||
result = runner.invoke(app, args)
|
result = runner.invoke(app, args)
|
||||||
assert result.exit_code == 42, result.output
|
assert result.exit_code == 42, result.output
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from chemenu.frontmatter_io import write_page
|
|||||||
from chemenu.lint_core import unfilled_sections
|
from chemenu.lint_core import unfilled_sections
|
||||||
from chemenu.provenance import cite_id, render_cite_block
|
from chemenu.provenance import cite_id, render_cite_block
|
||||||
from chemenu.version import Version
|
from chemenu.version import Version
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
def test_lint_detects_unparsable_frontmatter(kb_dir):
|
def test_lint_detects_unparsable_frontmatter(kb_dir):
|
||||||
@@ -454,7 +455,7 @@ def test_the_area_recommendation_says_the_layout_is_missing_when_it_is(kb_dir, t
|
|||||||
"additionalProperties: false\n",
|
"additionalProperties: false\n",
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(config, "TYPES_DIR", types_dir)
|
set_config_path(monkeypatch, "TYPES_DIR", types_dir)
|
||||||
monkeypatch.setattr(resolver, "_repo_root", tmp_path)
|
monkeypatch.setattr(resolver, "_repo_root", tmp_path)
|
||||||
|
|
||||||
_fill_collection(
|
_fill_collection(
|
||||||
@@ -672,9 +673,9 @@ def test_render_summary_says_so_when_there_is_nothing(kb_dir):
|
|||||||
def test_lint_writes_a_report_and_names_its_path(kb_dir, raw_dir, tmp_path, monkeypatch, capsys):
|
def test_lint_writes_a_report_and_names_its_path(kb_dir, raw_dir, tmp_path, monkeypatch, capsys):
|
||||||
"""Without a printed path the only way back to the full report is a second
|
"""Without a printed path the only way back to the full report is a second
|
||||||
lint call - the double-charge this default exists to remove."""
|
lint call - the double-charge this default exists to remove."""
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
lint_command(json_out=False, markdown_out=None, full=False, fail_on_error=False)
|
lint_command(json_out=False, markdown_out=None, full=False, fail_on_error=False)
|
||||||
|
|
||||||
written = tmp_path / "reports" / f"Lint Report {date.today().isoformat()}.md"
|
written = tmp_path / "reports" / f"Lint Report {date.today().isoformat()}.md"
|
||||||
@@ -686,9 +687,9 @@ def test_lint_writes_a_report_and_names_its_path(kb_dir, raw_dir, tmp_path, monk
|
|||||||
|
|
||||||
|
|
||||||
def test_lint_full_prints_the_whole_report(kb_dir, raw_dir, tmp_path, monkeypatch, capsys):
|
def test_lint_full_prints_the_whole_report(kb_dir, raw_dir, tmp_path, monkeypatch, capsys):
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
lint_command(json_out=False, markdown_out=None, full=True, fail_on_error=False)
|
lint_command(json_out=False, markdown_out=None, full=True, fail_on_error=False)
|
||||||
assert "None found." in capsys.readouterr().out
|
assert "None found." in capsys.readouterr().out
|
||||||
|
|
||||||
@@ -696,18 +697,18 @@ def test_lint_full_prints_the_whole_report(kb_dir, raw_dir, tmp_path, monkeypatc
|
|||||||
def test_lint_json_writes_no_report(kb_dir, raw_dir, tmp_path, monkeypatch, capsys):
|
def test_lint_json_writes_no_report(kb_dir, raw_dir, tmp_path, monkeypatch, capsys):
|
||||||
"""`--json` is a machine-readable dump of the same findings; writing a
|
"""`--json` is a machine-readable dump of the same findings; writing a
|
||||||
second copy to reports/ would be noise the caller never asked for."""
|
second copy to reports/ would be noise the caller never asked for."""
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
lint_command(json_out=True, markdown_out=None, full=False, fail_on_error=False)
|
lint_command(json_out=True, markdown_out=None, full=False, fail_on_error=False)
|
||||||
assert not (tmp_path / "reports").exists()
|
assert not (tmp_path / "reports").exists()
|
||||||
assert json.loads(capsys.readouterr().out)["page_count"] > 0
|
assert json.loads(capsys.readouterr().out)["page_count"] > 0
|
||||||
|
|
||||||
|
|
||||||
def test_lint_markdown_option_overrides_the_default_path(kb_dir, raw_dir, tmp_path, monkeypatch):
|
def test_lint_markdown_option_overrides_the_default_path(kb_dir, raw_dir, tmp_path, monkeypatch):
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
target = tmp_path / "elsewhere" / "report.md"
|
target = tmp_path / "elsewhere" / "report.md"
|
||||||
lint_command(json_out=False, markdown_out=target, full=False, fail_on_error=False)
|
lint_command(json_out=False, markdown_out=target, full=False, fail_on_error=False)
|
||||||
assert target.exists()
|
assert target.exists()
|
||||||
@@ -895,7 +896,7 @@ def test_unauthorised_label_is_judged_in_a_tree_that_is_not_the_configured_kb(
|
|||||||
)
|
)
|
||||||
elsewhere = tmp_path / "elsewhere"
|
elsewhere = tmp_path / "elsewhere"
|
||||||
elsewhere.mkdir()
|
elsewhere.mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", elsewhere)
|
set_config_path(monkeypatch, "ROOT", elsewhere)
|
||||||
assert config.KB_DIR != kb_dir
|
assert config.KB_DIR != kb_dir
|
||||||
|
|
||||||
report = run_lint(kb_dir)
|
report = run_lint(kb_dir)
|
||||||
@@ -1095,9 +1096,9 @@ def test_lint_reports_a_raw_path_over_the_budget(kb_dir, raw_dir):
|
|||||||
def test_lint_fail_on_error_ignores_long_paths(kb_dir, raw_dir, tmp_path, monkeypatch):
|
def test_lint_fail_on_error_ignores_long_paths(kb_dir, raw_dir, tmp_path, monkeypatch):
|
||||||
import typer
|
import typer
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
baseline = has_hard_errors(run_lint(kb_dir))
|
baseline = has_hard_errors(run_lint(kb_dir))
|
||||||
_long_page(kb_dir, 170)
|
_long_page(kb_dir, 170)
|
||||||
report = run_lint(kb_dir)
|
report = run_lint(kb_dir)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from chemenu.commands.log_append import (
|
|||||||
log_status,
|
log_status,
|
||||||
parse_log_entries,
|
parse_log_entries,
|
||||||
)
|
)
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
def test_log_entry_format_matches_convention():
|
def test_log_entry_format_matches_convention():
|
||||||
@@ -60,7 +61,7 @@ def test_ingests_since_last_lint_counts_from_the_start_when_never_linted():
|
|||||||
def test_log_status_reports_zero_with_no_log_file(tmp_path, monkeypatch, capsys):
|
def test_log_status_reports_zero_with_no_log_file(tmp_path, monkeypatch, capsys):
|
||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "LOG_FILE", tmp_path / "log.md")
|
set_config_path(monkeypatch, "LOG_FILE", tmp_path / "log.md")
|
||||||
log_status()
|
log_status()
|
||||||
assert "No kb/log.md yet" in capsys.readouterr().out
|
assert "No kb/log.md yet" in capsys.readouterr().out
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@ def test_log_status_warns_at_the_ten_ingest_threshold(tmp_path, monkeypatch, cap
|
|||||||
format_log_entry("ingest", f"raw/notes/{i}.md", today="2026-08-01") for i in range(10)
|
format_log_entry("ingest", f"raw/notes/{i}.md", today="2026-08-01") for i in range(10)
|
||||||
)
|
)
|
||||||
log_file.write_text(body, encoding="utf-8")
|
log_file.write_text(body, encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "LOG_FILE", log_file)
|
set_config_path(monkeypatch, "LOG_FILE", log_file)
|
||||||
|
|
||||||
log_status()
|
log_status()
|
||||||
out = capsys.readouterr().out
|
out = capsys.readouterr().out
|
||||||
@@ -111,7 +112,7 @@ def test_log_append_reports_an_unreadable_body_file_as_an_error(make_bad_file, t
|
|||||||
log_file = tmp_path / "log.md"
|
log_file = tmp_path / "log.md"
|
||||||
before = "# Wiki Log\n"
|
before = "# Wiki Log\n"
|
||||||
log_file.write_text(before, encoding="utf-8")
|
log_file.write_text(before, encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "LOG_FILE", log_file)
|
set_config_path(monkeypatch, "LOG_FILE", log_file)
|
||||||
bad_file = make_bad_file(tmp_path)
|
bad_file = make_bad_file(tmp_path)
|
||||||
|
|
||||||
with pytest.raises(typer.Exit) as exc:
|
with pytest.raises(typer.Exit) as exc:
|
||||||
@@ -129,7 +130,7 @@ def test_log_append_reads_the_body_from_body_file(tmp_path, monkeypatch):
|
|||||||
|
|
||||||
log_file = tmp_path / "log.md"
|
log_file = tmp_path / "log.md"
|
||||||
log_file.write_text("# Wiki Log\n", encoding="utf-8")
|
log_file.write_text("# Wiki Log\n", encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "LOG_FILE", log_file)
|
set_config_path(monkeypatch, "LOG_FILE", log_file)
|
||||||
body_file = tmp_path / "body.md"
|
body_file = tmp_path / "body.md"
|
||||||
body_file.write_text("Created [[Docker]].", encoding="utf-8")
|
body_file.write_text("Created [[Docker]].", encoding="utf-8")
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import typer
|
|||||||
from chemenu import config, kb_state
|
from chemenu import config, kb_state
|
||||||
from chemenu.commands import migrate_cmd
|
from chemenu.commands import migrate_cmd
|
||||||
from chemenu.version import Version, VersionError
|
from chemenu.version import Version, VersionError
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
CHANGES = "# Changelog\n\n---\n\n## 1.0.0 - 2026-08-30 - First\n\nBody.\n"
|
CHANGES = "# Changelog\n\n---\n\n## 1.0.0 - 2026-08-30 - First\n\nBody.\n"
|
||||||
|
|
||||||
@@ -54,8 +55,8 @@ def instance(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
write_migration(migrations, "1.2.0", "ancient")
|
write_migration(migrations, "1.2.0", "ancient")
|
||||||
write_migration(migrations, "2.1.0", "not-installed-yet")
|
write_migration(migrations, "2.1.0", "not-installed-yet")
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "INSTRUCTIONS_DIR", instructions)
|
set_config_path(monkeypatch, "INSTRUCTIONS_DIR", instructions)
|
||||||
monkeypatch.setenv("WIKI_AUTHOR", "Test Author")
|
monkeypatch.setenv("WIKI_AUTHOR", "Test Author")
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|
||||||
@@ -226,8 +227,8 @@ def git_instance(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
["git", "commit", "-q", "-m", "seed"], cwd=tmp_path, check=True, capture_output=True
|
["git", "commit", "-q", "-m", "seed"], cwd=tmp_path, check=True, capture_output=True
|
||||||
)
|
)
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", tmp_path / "kb")
|
set_config_path(monkeypatch, "KB_DIR", tmp_path / "kb")
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|
||||||
|
|
||||||
@@ -319,8 +320,8 @@ def test_verify_confirms_three_moved_pages_compare_as_themselves(tmp_path, monke
|
|||||||
["git", "commit", "-q", "-m", "seed"], cwd=tmp_path, check=True, capture_output=True
|
["git", "commit", "-q", "-m", "seed"], cwd=tmp_path, check=True, capture_output=True
|
||||||
)
|
)
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "KB_DIR", tmp_path / "kb")
|
set_config_path(monkeypatch, "KB_DIR", tmp_path / "kb")
|
||||||
|
|
||||||
moved_dir = kb / "moved"
|
moved_dir = kb / "moved"
|
||||||
moved_dir.mkdir()
|
moved_dir.mkdir()
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from chemenu.commands._util import coerce_set_value, parse_set_fields
|
|||||||
from chemenu.commands.new_page import _page_subdir
|
from chemenu.commands.new_page import _page_subdir
|
||||||
from chemenu.frontmatter_io import read_page
|
from chemenu.frontmatter_io import read_page
|
||||||
from typer.testing import CliRunner
|
from typer.testing import CliRunner
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
@@ -159,7 +160,7 @@ def _invoke_new(monkeypatch, kb_dir, args):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
return runner.invoke(app, args)
|
return runner.invoke(app, args)
|
||||||
|
|
||||||
|
|
||||||
@@ -521,7 +522,7 @@ def _fixture_raw_file(monkeypatch, kb_dir, relative: str) -> None:
|
|||||||
|
|
||||||
from chemenu.tests.conftest import use_shipped_type_specs
|
from chemenu.tests.conftest import use_shipped_type_specs
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", kb_dir.parent)
|
set_config_path(monkeypatch, "ROOT", kb_dir.parent)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
path = kb_dir.parent / relative
|
path = kb_dir.parent / relative
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
@@ -861,7 +862,7 @@ def test_raw_files_error_points_at_the_comma_split(monkeypatch, kb_dir, raw_dir)
|
|||||||
# depend on the caller's git config (see the test-hardening issue).
|
# depend on the caller's git config (see the test-hardening issue).
|
||||||
monkeypatch.setenv("WIKI_AUTHOR", "Fixture Author")
|
monkeypatch.setenv("WIKI_AUTHOR", "Fixture Author")
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", kb_dir.parent)
|
set_config_path(monkeypatch, "ROOT", kb_dir.parent)
|
||||||
result = _invoke_new(monkeypatch, kb_dir, [
|
result = _invoke_new(monkeypatch, kb_dir, [
|
||||||
"new", "source", "--name", "Split Path",
|
"new", "source", "--name", "Split Path",
|
||||||
"--set", "source_type=notes",
|
"--set", "source_type=notes",
|
||||||
@@ -884,7 +885,7 @@ def _invoke_new_instruction(monkeypatch, tmp_path, args):
|
|||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
from chemenu.tests.conftest import use_shipped_type_specs
|
from chemenu.tests.conftest import use_shipped_type_specs
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
(tmp_path / "instructions").mkdir(parents=True, exist_ok=True)
|
(tmp_path / "instructions").mkdir(parents=True, exist_ok=True)
|
||||||
return runner.invoke(app, args)
|
return runner.invoke(app, args)
|
||||||
@@ -923,7 +924,7 @@ def test_source_page_accepts_a_raw_file_whose_name_has_a_comma(monkeypatch, kb_d
|
|||||||
monkeypatch.setenv("WIKI_AUTHOR", "Fixture Author")
|
monkeypatch.setenv("WIKI_AUTHOR", "Fixture Author")
|
||||||
|
|
||||||
(raw_dir / "notes" / "Versioning, CI-CD.md").write_text("# notes\n", encoding="utf-8")
|
(raw_dir / "notes" / "Versioning, CI-CD.md").write_text("# notes\n", encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "ROOT", kb_dir.parent)
|
set_config_path(monkeypatch, "ROOT", kb_dir.parent)
|
||||||
result = _invoke_new(monkeypatch, kb_dir, [
|
result = _invoke_new(monkeypatch, kb_dir, [
|
||||||
"new", "source", "--name", "Comma Source",
|
"new", "source", "--name", "Comma Source",
|
||||||
"--set", r"raw_files=raw/notes/Versioning\, CI-CD.md",
|
"--set", r"raw_files=raw/notes/Versioning\, CI-CD.md",
|
||||||
|
|||||||
@@ -6,13 +6,14 @@ import typer
|
|||||||
from chemenu.commands import page_ops
|
from chemenu.commands import page_ops
|
||||||
from chemenu.frontmatter_io import read_page, write_page
|
from chemenu.frontmatter_io import read_page, write_page
|
||||||
from chemenu.provenance import cite_id
|
from chemenu.provenance import cite_id
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def patched_wiki(kb_dir, monkeypatch):
|
def patched_wiki(kb_dir, monkeypatch):
|
||||||
"""Point config.KB_DIR at the fixture wiki so the commands never touch
|
"""Point config.KB_DIR at the fixture wiki so the commands never touch
|
||||||
the real one."""
|
the real one."""
|
||||||
monkeypatch.setattr("chemenu.config.KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
return kb_dir
|
return kb_dir
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from typer.testing import CliRunner
|
|||||||
|
|
||||||
from chemenu.commands.index_build import plan_index
|
from chemenu.commands.index_build import plan_index
|
||||||
from chemenu.commands.lint import HARD_ERROR_KEYS, has_hard_errors, run_lint
|
from chemenu.commands.lint import HARD_ERROR_KEYS, has_hard_errors, run_lint
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -51,9 +52,9 @@ def empty_kb(tmp_path, monkeypatch):
|
|||||||
raw = tmp_path / "raw"
|
raw = tmp_path / "raw"
|
||||||
raw.mkdir()
|
raw.mkdir()
|
||||||
|
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb)
|
set_config_path(monkeypatch, "KB_DIR", kb)
|
||||||
monkeypatch.setattr(config, "INDEX_FILE", kb / "index.md")
|
set_config_path(monkeypatch, "INDEX_FILE", kb / "index.md")
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw)
|
set_config_path(monkeypatch, "RAW_DIR", raw)
|
||||||
return kb
|
return kb
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ from pathlib import Path
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from chemenu import config, prerequisites, titles, toolpaths
|
from chemenu import config, prerequisites, titles, toolpaths
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
TOOLS = config._PACKAGE_ROOT / "tools"
|
TOOLS = config._PACKAGE_ROOT / "tools"
|
||||||
|
|
||||||
@@ -1035,7 +1036,7 @@ def test_git_and_rg_start_from_the_recorded_paths_not_from_path(tmp_path, monkey
|
|||||||
subprocess.run(["git", "config", "user.name", "Recorded Git"], cwd=repo, check=True)
|
subprocess.run(["git", "config", "user.name", "Recorded Git"], cwd=repo, check=True)
|
||||||
(repo / "kb").mkdir()
|
(repo / "kb").mkdir()
|
||||||
(repo / "kb" / "Page.md").write_text("---\ntitle: Page\n---\nkingfisher\n", encoding="utf-8")
|
(repo / "kb" / "Page.md").write_text("---\ntitle: Page\n---\nkingfisher\n", encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "ROOT", repo)
|
set_config_path(monkeypatch, "ROOT", repo)
|
||||||
monkeypatch.setenv("PATH", str(tmp_path / "empty"))
|
monkeypatch.setenv("PATH", str(tmp_path / "empty"))
|
||||||
|
|
||||||
assert config.default_author() == "Recorded Git"
|
assert config.default_author() == "Recorded Git"
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ from chemenu.provenance import (
|
|||||||
uncovered_raw_files,
|
uncovered_raw_files,
|
||||||
)
|
)
|
||||||
from chemenu.kb_scan import load_kb_pages
|
from chemenu.kb_scan import load_kb_pages
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -247,7 +248,7 @@ def test_source_pages_by_raw_file_uses_legacy_source_fallback(kb_dir, raw_dir):
|
|||||||
def test_uncovered_raw_files_detects_ingested_gap(kb_dir, raw_dir, monkeypatch):
|
def test_uncovered_raw_files_detects_ingested_gap(kb_dir, raw_dir, monkeypatch):
|
||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
pages = load_kb_pages(kb_dir)
|
pages = load_kb_pages(kb_dir)
|
||||||
uncovered = uncovered_raw_files(raw_dir, pages)
|
uncovered = uncovered_raw_files(raw_dir, pages)
|
||||||
assert "raw/notes/Uningested.md" in uncovered
|
assert "raw/notes/Uningested.md" in uncovered
|
||||||
@@ -257,7 +258,7 @@ def test_uncovered_raw_files_detects_ingested_gap(kb_dir, raw_dir, monkeypatch):
|
|||||||
def test_broken_raw_refs_detects_dangling_path(kb_dir, raw_dir, monkeypatch):
|
def test_broken_raw_refs_detects_dangling_path(kb_dir, raw_dir, monkeypatch):
|
||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
write_page(
|
write_page(
|
||||||
kb_dir / "sources/Source - Ghost.md",
|
kb_dir / "sources/Source - Ghost.md",
|
||||||
{
|
{
|
||||||
@@ -347,9 +348,9 @@ def test_sources_coverage_command_reports_uncovered_file(kb_dir, raw_dir, monkey
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
|
|
||||||
result = runner.invoke(app, ["sources", "coverage", "--json"])
|
result = runner.invoke(app, ["sources", "coverage", "--json"])
|
||||||
assert result.exit_code == 0, result.output
|
assert result.exit_code == 0, result.output
|
||||||
@@ -360,9 +361,9 @@ def test_sources_trace_by_raw_and_by_page(kb_dir, raw_dir, monkeypatch):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
|
|
||||||
write_page(
|
write_page(
|
||||||
kb_dir / "entities/systems/aurora.md",
|
kb_dir / "entities/systems/aurora.md",
|
||||||
@@ -389,8 +390,8 @@ def test_new_source_with_multiple_raw_files(kb_dir, raw_dir, monkeypatch):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
# This test is about raw_files:, not about authorship - but `new source`
|
# This test is about raw_files:, not about authorship - but `new source`
|
||||||
# refuses to stamp a placeholder author, and the fixture root has no git
|
# refuses to stamp a placeholder author, and the fixture root has no git
|
||||||
# identity. Naming one keeps the test off the runner's global git config.
|
# identity. Naming one keeps the test off the runner's global git config.
|
||||||
@@ -413,8 +414,8 @@ def test_new_source_rejects_nonexistent_raw_path(kb_dir, raw_dir, monkeypatch):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
|
|
||||||
result = runner.invoke(app, [
|
result = runner.invoke(app, [
|
||||||
"new", "source", "--name", "Bad", "--set", "raw_files=raw/notes/Nope.md",
|
"new", "source", "--name", "Bad", "--set", "raw_files=raw/notes/Nope.md",
|
||||||
@@ -426,8 +427,8 @@ def test_lint_flags_citation_not_in_frontmatter_sources(kb_dir, raw_dir, monkeyp
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.commands.lint import run_lint
|
from chemenu.commands.lint import run_lint
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
|
|
||||||
refs, block = _footnote_block(("Source - Aurora", None))
|
refs, block = _footnote_block(("Source - Aurora", None))
|
||||||
write_page(
|
write_page(
|
||||||
@@ -448,8 +449,8 @@ def test_lint_no_drift_when_source_declared(kb_dir, raw_dir, monkeypatch):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.commands.lint import run_lint
|
from chemenu.commands.lint import run_lint
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
|
|
||||||
refs, block = _footnote_block(("Source - Aurora", None))
|
refs, block = _footnote_block(("Source - Aurora", None))
|
||||||
write_page(
|
write_page(
|
||||||
@@ -469,8 +470,8 @@ def test_lint_unmarked_provenance_flags_empty_sources_without_general(kb_dir, ra
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.commands.lint import run_lint
|
from chemenu.commands.lint import run_lint
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
report = run_lint(kb_dir)
|
report = run_lint(kb_dir)
|
||||||
# gdeploy in the base fixture has sources: [] and no provenance field at all.
|
# gdeploy in the base fixture has sources: [] and no provenance field at all.
|
||||||
assert "gdeploy" in report["unmarked_provenance"]
|
assert "gdeploy" in report["unmarked_provenance"]
|
||||||
@@ -480,8 +481,8 @@ def test_lint_does_not_flag_source_page_self_citation(kb_dir, raw_dir, monkeypat
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.commands.lint import run_lint
|
from chemenu.commands.lint import run_lint
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", raw_dir.parent)
|
set_config_path(monkeypatch, "ROOT", raw_dir.parent)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", raw_dir)
|
set_config_path(monkeypatch, "RAW_DIR", raw_dir)
|
||||||
|
|
||||||
refs, block = _footnote_block(("Source - Aurora", "Aurora.md"))
|
refs, block = _footnote_block(("Source - Aurora", "Aurora.md"))
|
||||||
write_page(
|
write_page(
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from chemenu import version as version_mod
|
|||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
from chemenu.commands import dist_cmd, docs_verify, instructions_cmd
|
from chemenu.commands import dist_cmd, docs_verify, instructions_cmd
|
||||||
from chemenu.type_resolver import resolver
|
from chemenu.type_resolver import resolver
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -166,7 +167,7 @@ def exported_instance(tmp_path, monkeypatch):
|
|||||||
instance may: a type-spec of its own making, and a skill of its own."""
|
instance may: a type-spec of its own making, and a skill of its own."""
|
||||||
target = tmp_path / "instance"
|
target = tmp_path / "instance"
|
||||||
dist_cmd.run_export(target)
|
dist_cmd.run_export(target)
|
||||||
monkeypatch.setattr(config, "ROOT", target)
|
set_config_path(monkeypatch, "ROOT", target)
|
||||||
monkeypatch.setattr(resolver, "_repo_root", target)
|
monkeypatch.setattr(resolver, "_repo_root", target)
|
||||||
for template in sorted((target / "types").glob("*.template")):
|
for template in sorted((target / "types").glob("*.template")):
|
||||||
template.rename(template.with_suffix(""))
|
template.rename(template.with_suffix(""))
|
||||||
@@ -267,7 +268,7 @@ def _page_type(description: str = "A fixture type.") -> reference_doc.PageType:
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def tree(tmp_path, monkeypatch):
|
def tree(tmp_path, monkeypatch):
|
||||||
real_root = config.ROOT
|
real_root = config.ROOT
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
records = {"frobnicate": _record("frobnicate"), "gate keep": _record("gate keep", ("mass-update",))}
|
records = {"frobnicate": _record("frobnicate"), "gate keep": _record("gate keep", ("mass-update",))}
|
||||||
monkeypatch.setattr(cli_contract, "all_records", lambda: dict(records))
|
monkeypatch.setattr(cli_contract, "all_records", lambda: dict(records))
|
||||||
monkeypatch.setattr(cli_contract, "GROUPS", GROUPS)
|
monkeypatch.setattr(cli_contract, "GROUPS", GROUPS)
|
||||||
@@ -408,7 +409,7 @@ def test_a_page_without_a_group_fails(tree):
|
|||||||
|
|
||||||
|
|
||||||
def test_a_tree_without_docs_passes(tmp_path, monkeypatch):
|
def test_a_tree_without_docs_passes(tmp_path, monkeypatch):
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
assert docs_verify.check_reference_regions() == []
|
assert docs_verify.check_reference_regions() == []
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ from chemenu.cli import app
|
|||||||
from chemenu.commands.run_budget import is_exempt
|
from chemenu.commands.run_budget import is_exempt
|
||||||
from chemenu.errors import ValidationError
|
from chemenu.errors import ValidationError
|
||||||
from chemenu.frontmatter_io import write_page
|
from chemenu.frontmatter_io import write_page
|
||||||
from chemenu.tests.conftest import use_shipped_type_specs, write_settings
|
from chemenu.tests.conftest import set_config_path, use_shipped_type_specs, write_settings
|
||||||
from chemenu.review import (
|
from chemenu.review import (
|
||||||
CHECK_NO_OPEN_LOOP,
|
CHECK_NO_OPEN_LOOP,
|
||||||
CHECK_PROJECT_AGE_UNKNOWN,
|
CHECK_PROJECT_AGE_UNKNOWN,
|
||||||
@@ -322,7 +322,7 @@ def test_d3_caldav_project_with_no_determinable_created_date_is_its_own_finding(
|
|||||||
def test_d3_text_and_json_output_agree(tmp_path, monkeypatch):
|
def test_d3_text_and_json_output_agree(tmp_path, monkeypatch):
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
projects = {"p1": {"id": "p1", "title": "Kueche renovieren", "created": _ms(2026, 1, 1),
|
projects = {"p1": {"id": "p1", "title": "Kueche renovieren", "created": _ms(2026, 1, 1),
|
||||||
"taskIds": ["t1"], "backlogTaskIds": []}}
|
"taskIds": ["t1"], "backlogTaskIds": []}}
|
||||||
@@ -463,7 +463,7 @@ def test_unreachable_provider_skips_the_project_list_checks_but_not_someday(tmp_
|
|||||||
def test_cli_no_provider_exits_1_with_a_clear_message(tmp_path, monkeypatch):
|
def test_cli_no_provider_exits_1_with_a_clear_message(tmp_path, monkeypatch):
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
(tmp_path / "kb" / "gtd").mkdir(parents=True)
|
(tmp_path / "kb" / "gtd").mkdir(parents=True)
|
||||||
result = runner.invoke(app, ["review"])
|
result = runner.invoke(app, ["review"])
|
||||||
@@ -474,7 +474,7 @@ def test_cli_no_provider_exits_1_with_a_clear_message(tmp_path, monkeypatch):
|
|||||||
def test_cli_incomplete_report_exits_1_and_still_prints(tmp_path, monkeypatch):
|
def test_cli_incomplete_report_exits_1_and_still_prints(tmp_path, monkeypatch):
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
_write_tasks_config(tmp_path, tmp_path / "does-not-exist-dir")
|
_write_tasks_config(tmp_path, tmp_path / "does-not-exist-dir")
|
||||||
(tmp_path / "kb" / "gtd").mkdir(parents=True)
|
(tmp_path / "kb" / "gtd").mkdir(parents=True)
|
||||||
@@ -491,7 +491,7 @@ def test_cli_json_and_text_agree_on_findings(tmp_path, monkeypatch):
|
|||||||
against the CLI's own `--json`."""
|
against the CLI's own `--json`."""
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
projects = {"p1": {"id": "p1", "title": "Ship Chemenu 7.0", "created": _ms(2026, 1, 1),
|
projects = {"p1": {"id": "p1", "title": "Ship Chemenu 7.0", "created": _ms(2026, 1, 1),
|
||||||
"taskIds": [], "backlogTaskIds": []}}
|
"taskIds": [], "backlogTaskIds": []}}
|
||||||
@@ -539,7 +539,7 @@ def test_report_names_its_source_and_the_snapshot_age(tmp_path):
|
|||||||
def test_cli_shows_the_source_in_both_render_forms(tmp_path, monkeypatch):
|
def test_cli_shows_the_source_in_both_render_forms(tmp_path, monkeypatch):
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
projects = {"p1": {"id": "p1", "title": "Ship Chemenu 7.0", "created": _ms(2026, 1, 1),
|
projects = {"p1": {"id": "p1", "title": "Ship Chemenu 7.0", "created": _ms(2026, 1, 1),
|
||||||
"taskIds": [], "backlogTaskIds": []}}
|
"taskIds": [], "backlogTaskIds": []}}
|
||||||
@@ -579,7 +579,7 @@ def test_a_run_leaves_the_git_tree_untouched(tmp_path, monkeypatch):
|
|||||||
subprocess.run(["git", "add", "-A"], cwd=tmp_path, check=True)
|
subprocess.run(["git", "add", "-A"], cwd=tmp_path, check=True)
|
||||||
subprocess.run(["git", "commit", "-q", "-m", "fixture"], cwd=tmp_path, check=True)
|
subprocess.run(["git", "commit", "-q", "-m", "fixture"], cwd=tmp_path, check=True)
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
use_shipped_type_specs(monkeypatch)
|
use_shipped_type_specs(monkeypatch)
|
||||||
before = subprocess.run(
|
before = subprocess.run(
|
||||||
["git", "status", "--porcelain"], cwd=tmp_path, capture_output=True, text=True, check=True
|
["git", "status", "--porcelain"], cwd=tmp_path, capture_output=True, text=True, check=True
|
||||||
@@ -594,7 +594,7 @@ def test_a_run_leaves_the_git_tree_untouched(tmp_path, monkeypatch):
|
|||||||
def test_cli_override_naming_a_missing_file_is_an_error_naming_the_path(tmp_path, monkeypatch):
|
def test_cli_override_naming_a_missing_file_is_an_error_naming_the_path(tmp_path, monkeypatch):
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setenv("WIKITOOL_TASKS_CONFIG", str(tmp_path / "gone.json"))
|
monkeypatch.setenv("WIKITOOL_TASKS_CONFIG", str(tmp_path / "gone.json"))
|
||||||
result = runner.invoke(app, ["review"])
|
result = runner.invoke(app, ["review"])
|
||||||
assert result.exit_code == 1
|
assert result.exit_code == 1
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ from chemenu.cli import app
|
|||||||
from chemenu.commands import _util, docs_verify, doctor
|
from chemenu.commands import _util, docs_verify, doctor
|
||||||
from chemenu.config_shapes import CHECKOUT, INSTANCE, SECRET, Field, Shape
|
from chemenu.config_shapes import CHECKOUT, INSTANCE, SECRET, Field, Shape
|
||||||
from chemenu.errors import ValidationError
|
from chemenu.errors import ValidationError
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ TRACKER = Shape(
|
|||||||
def root(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
def root(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
||||||
tree = tmp_path / "instance"
|
tree = tmp_path / "instance"
|
||||||
tree.mkdir()
|
tree.mkdir()
|
||||||
monkeypatch.setattr(config, "ROOT", tree)
|
set_config_path(monkeypatch, "ROOT", tree)
|
||||||
monkeypatch.setattr(config_shapes, "SETTINGS_SECTIONS", (TRACKER,))
|
monkeypatch.setattr(config_shapes, "SETTINGS_SECTIONS", (TRACKER,))
|
||||||
return tree
|
return tree
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import pytest
|
|||||||
from typer.testing import CliRunner
|
from typer.testing import CliRunner
|
||||||
|
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
from chemenu.tests.conftest import write_settings
|
from chemenu.tests.conftest import set_config_path, write_settings
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ def _invoke(monkeypatch, kb_dir, args):
|
|||||||
import chemenu.config as config
|
import chemenu.config as config
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
return runner.invoke(app, args)
|
return runner.invoke(app, args)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from pathlib import Path
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from chemenu.telemetry import policy
|
from chemenu.telemetry import policy
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
@@ -122,7 +123,7 @@ def test_the_env_override_is_always_live_even_with_a_cached_root(tmp_path, monke
|
|||||||
def test_resolve_defaults_to_config_root(tmp_path, monkeypatch):
|
def test_resolve_defaults_to_config_root(tmp_path, monkeypatch):
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
_stamp(tmp_path)
|
_stamp(tmp_path)
|
||||||
assert policy.resolve().enabled is False
|
assert policy.resolve().enabled is False
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from chemenu import blocks, toc
|
from chemenu import blocks, toc
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
def _body(n_lines: int, sections: int) -> str:
|
def _body(n_lines: int, sections: int) -> str:
|
||||||
@@ -192,7 +193,7 @@ def test_target_files_takes_a_template_only_for_a_file_already_in_scope(tmp_path
|
|||||||
because `USER.md` itself is not reference material this region applies to."""
|
because `USER.md` itself is not reference material this region applies to."""
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
(tmp_path / "kb").mkdir()
|
(tmp_path / "kb").mkdir()
|
||||||
for name in ("kb/CONVENTIONS.md", "kb/CONVENTIONS.md.template", "USER.md.template"):
|
for name in ("kb/CONVENTIONS.md", "kb/CONVENTIONS.md.template", "USER.md.template"):
|
||||||
(tmp_path / name).write_text("# A file\n", encoding="utf-8")
|
(tmp_path / name).write_text("# A file\n", encoding="utf-8")
|
||||||
@@ -238,7 +239,7 @@ def test_target_files_leaves_out_subtype_templates(tmp_path, monkeypatch):
|
|||||||
shape, stays in."""
|
shape, stays in."""
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
|
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
types_dir = tmp_path / "types"
|
types_dir = tmp_path / "types"
|
||||||
types_dir.mkdir()
|
types_dir.mkdir()
|
||||||
long_body = _body(150, 6)
|
long_body = _body(150, 6)
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ from typer.testing import CliRunner
|
|||||||
from chemenu import config
|
from chemenu import config
|
||||||
from chemenu.commands.touch import touch_command
|
from chemenu.commands.touch import touch_command
|
||||||
from chemenu.frontmatter_io import read_page
|
from chemenu.frontmatter_io import read_page
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def touch_wiki(kb_dir, monkeypatch):
|
def touch_wiki(kb_dir, monkeypatch):
|
||||||
monkeypatch.setattr(config, "KB_DIR", kb_dir)
|
set_config_path(monkeypatch, "KB_DIR", kb_dir)
|
||||||
return kb_dir
|
return kb_dir
|
||||||
|
|
||||||
|
|
||||||
@@ -191,7 +192,7 @@ def test_confidence_base_flag_no_longer_exists(touch_wiki, monkeypatch):
|
|||||||
import chemenu.config as cfg
|
import chemenu.config as cfg
|
||||||
from chemenu.cli import app
|
from chemenu.cli import app
|
||||||
|
|
||||||
monkeypatch.setattr(cfg, "KB_DIR", touch_wiki)
|
set_config_path(monkeypatch, "KB_DIR", touch_wiki)
|
||||||
result = runner.invoke(app, ["touch", "--page", "aurora", "--confidence-base", "0.9"])
|
result = runner.invoke(app, ["touch", "--page", "aurora", "--confidence-base", "0.9"])
|
||||||
assert result.exit_code != 0
|
assert result.exit_code != 0
|
||||||
assert "confidence-base" in result.output.lower() or "no such option" in result.output.lower()
|
assert "confidence-base" in result.output.lower() or "no such option" in result.output.lower()
|
||||||
@@ -218,7 +219,7 @@ def test_set_validates_against_the_schema_before_writing(touch_wiki):
|
|||||||
def test_set_raw_files_checks_the_path_exists(touch_wiki, raw_dir, monkeypatch):
|
def test_set_raw_files_checks_the_path_exists(touch_wiki, raw_dir, monkeypatch):
|
||||||
"""`touch` writes this field now, so it owes the same filesystem check
|
"""`touch` writes this field now, so it owes the same filesystem check
|
||||||
`new` does - the schema cannot express it."""
|
`new` does - the schema cannot express it."""
|
||||||
monkeypatch.setattr(config, "ROOT", touch_wiki.parent)
|
set_config_path(monkeypatch, "ROOT", touch_wiki.parent)
|
||||||
with pytest.raises(typer.Exit):
|
with pytest.raises(typer.Exit):
|
||||||
_touch(page_title="Source - Aurora", set_fields=["raw_files=raw/notes/absent.md"])
|
_touch(page_title="Source - Aurora", set_fields=["raw_files=raw/notes/absent.md"])
|
||||||
|
|
||||||
@@ -226,7 +227,7 @@ def test_set_raw_files_checks_the_path_exists(touch_wiki, raw_dir, monkeypatch):
|
|||||||
def test_set_raw_files_accepts_an_existing_path_with_a_comma(touch_wiki, raw_dir, monkeypatch):
|
def test_set_raw_files_accepts_an_existing_path_with_a_comma(touch_wiki, raw_dir, monkeypatch):
|
||||||
"""The repair the whole issue started from: a raw file moved, and the page
|
"""The repair the whole issue started from: a raw file moved, and the page
|
||||||
pointing at it has to follow without anyone editing frontmatter."""
|
pointing at it has to follow without anyone editing frontmatter."""
|
||||||
monkeypatch.setattr(config, "ROOT", touch_wiki.parent)
|
set_config_path(monkeypatch, "ROOT", touch_wiki.parent)
|
||||||
(raw_dir / "notes" / "Versioning, CI-CD.md").write_text("# notes\n", encoding="utf-8")
|
(raw_dir / "notes" / "Versioning, CI-CD.md").write_text("# notes\n", encoding="utf-8")
|
||||||
_touch(
|
_touch(
|
||||||
page_title="Source - Aurora",
|
page_title="Source - Aurora",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from chemenu.commands.upload_cmd import (
|
|||||||
upload_reject_command,
|
upload_reject_command,
|
||||||
upload_show_command,
|
upload_show_command,
|
||||||
)
|
)
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
CONTENT = b"a test submission for the CLI layer\n"
|
CONTENT = b"a test submission for the CLI layer\n"
|
||||||
CONTENT_B64 = base64.b64encode(CONTENT).decode("ascii")
|
CONTENT_B64 = base64.b64encode(CONTENT).decode("ascii")
|
||||||
@@ -33,7 +34,7 @@ _CFG = upload.Channel(
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def root(tmp_path, monkeypatch):
|
def root(tmp_path, monkeypatch):
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
(tmp_path / "incoming").mkdir()
|
(tmp_path / "incoming").mkdir()
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import typer
|
|||||||
from chemenu import config, version as version_mod
|
from chemenu import config, version as version_mod
|
||||||
from chemenu.commands import version_cmd
|
from chemenu.commands import version_cmd
|
||||||
from chemenu.version import Version, VersionError
|
from chemenu.version import Version, VersionError
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
CHANGES_HEADER = "# Changelog\n\nPreamble.\n\n---\n\n"
|
CHANGES_HEADER = "# Changelog\n\nPreamble.\n\n---\n\n"
|
||||||
|
|
||||||
@@ -28,8 +29,8 @@ def tree(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|||||||
)
|
)
|
||||||
instructions = tmp_path / "instructions"
|
instructions = tmp_path / "instructions"
|
||||||
(instructions / "migrations").mkdir(parents=True)
|
(instructions / "migrations").mkdir(parents=True)
|
||||||
monkeypatch.setattr(config, "ROOT", tmp_path)
|
set_config_path(monkeypatch, "ROOT", tmp_path)
|
||||||
monkeypatch.setattr(config, "INSTRUCTIONS_DIR", instructions)
|
set_config_path(monkeypatch, "INSTRUCTIONS_DIR", instructions)
|
||||||
monkeypatch.setenv("WIKI_AUTHOR", "Test Author")
|
monkeypatch.setenv("WIKI_AUTHOR", "Test Author")
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import typer
|
|||||||
|
|
||||||
from chemenu import config
|
from chemenu import config
|
||||||
from chemenu.commands import work_cmd
|
from chemenu.commands import work_cmd
|
||||||
|
from chemenu.tests.conftest import set_config_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@@ -12,9 +13,9 @@ def patched_work(tmp_path, monkeypatch):
|
|||||||
root = tmp_path
|
root = tmp_path
|
||||||
(root / "raw" / "documents" / "almanac").mkdir(parents=True)
|
(root / "raw" / "documents" / "almanac").mkdir(parents=True)
|
||||||
(root / "raw" / "documents" / "almanac" / "README.md").write_text("x", encoding="utf-8")
|
(root / "raw" / "documents" / "almanac" / "README.md").write_text("x", encoding="utf-8")
|
||||||
monkeypatch.setattr(config, "ROOT", root)
|
set_config_path(monkeypatch, "ROOT", root)
|
||||||
monkeypatch.setattr(config, "RAW_DIR", root / "raw")
|
set_config_path(monkeypatch, "RAW_DIR", root / "raw")
|
||||||
monkeypatch.setattr(config, "WORK_DIR", root / "work")
|
set_config_path(monkeypatch, "WORK_DIR", root / "work")
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
pyyaml>=6.0
|
pyyaml>=6.0
|
||||||
typer>=0.12
|
typer>=0.29.1
|
||||||
rich>=13.0
|
rich>=13.0
|
||||||
jsonschema>=4.18
|
jsonschema>=4.18
|
||||||
referencing>=0.30
|
referencing>=0.30
|
||||||
|
|||||||
Reference in new issue
Block a user