test(validation): cover genuine remote retrieval and the warm cache - #139
Open
LukasGold wants to merge 1 commit into
Open
test(validation): cover genuine remote retrieval and the warm cache#139LukasGold wants to merge 1 commit into
LukasGold wants to merge 1 commit into
Conversation
- add a loopback HTTP server test proving Resolver fetches @context over a real socket, since the existing remote_context fixture only ever crosses a directory boundary, never the filesystem - add a committed disk-cache entry, keyed by Resolver's own sha256 scheme, proving an offline run can use a warmed cache without a network mock standing in for retrieval - mark tests/data/resolver_cache/ -text so its LF fixture survives autocrlf checkouts
Contributor
Release previewNo version bump from the current commits (stays at Changelog preview (truncated)Preview via python-semantic-release and conventional commits. |
Contributor
📊 Benchmark ResultsClick to see benchmark comparisonThreshold: 1.3x (30% slower triggers a regression warning) Note: Benchmarks are informational only and won't fail the build. 💡 Tip: Download the |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #128.
tests/data/oold/remote_context/is named for a remote@contextbut exercises a cross-directory one. Across the whole corpus: 25 same-directory references, 6 cross-directory, and 0 true HTTP. SoResolvernever opened a socket in any test.That is a prerequisite rather than a tidy-up.
Resolver's fetch, disk cache andoffline=Truerefusal are exactly the layer #119 proposes moving ontoreferencing, and until now a regression in retrieval would have passed CI untouched.What this adds
A genuinely remote fetch.
test_a_genuinely_remote_context_is_fetched_over_httpstarts a loopbackThreadingHTTPServeron an OS-assigned port, templates a schema and its remote@contextintotmp_path, and runs the full pipeline withoffline=Falseand an isolatedcache_dir. The handler records every request it serves, and the test asserts the context was actually requested over the wire rather than resolved from disk by accident. A committed fixture cannot carry the URL, since the port varies per run, which is why the schema is templated rather than checked in.The warm cache and the offline refusal.
test_a_warm_cache_entry_resolves_offline_and_a_missing_one_is_refusedcommits one disk-cache entry undertests/data/resolver_cache/and asserts both halves of the offline guarantee: a warmed entry satisfies a fetch underoffline=True, and a URL with no entry is refused. The filename is the sha256 digestResolver._cache_filederives from the URL, not an invented key.Shape 2 from the issue, monkeypatching the retrieval hook, was deliberately not implemented: it skips the code under test. The issue reserves it for the case where the loopback server proves flaky in CI.
The name
remote_context/is not renamed. It gets a genuinely remote sibling instead, so the directory's name becomes true rather than being redefined. This also keeps the change clear ofdocs/maintaining-meta-schemas.md, which #123 is editing.No production code changed
ResolverandDocumentLoaderwere exercisable as-is through the existingOptions.cache_dirandofflineparameters. That matters for #119: the tests describe the current retrieval contract from the outside, so they stay meaningful across the rewrite.Verification
mainmake check: cleanuv run oold validate tests/data/oold --offline: PASS, 380 ok, 21 warnings, unchangedbase_urlat a closed port, and failed with a real connection refusal oncontext.remote,roundtrip.generatedandcontext.predicates, then was restored. A network test that passes without making a request is worse than no test, so this was checked rather than assumed..gitattributesgains a-textrule for the new directory, so the committed cache entry keeps LF endings under Windowscore.autocrlf.