Skip to content

test(validation): cover genuine remote retrieval and the warm cache - #139

Open
LukasGold wants to merge 1 commit into
mainfrom
test/remote-context-fixture
Open

test(validation): cover genuine remote retrieval and the warm cache#139
LukasGold wants to merge 1 commit into
mainfrom
test/remote-context-fixture

Conversation

@LukasGold

Copy link
Copy Markdown

Closes #128.

tests/data/oold/remote_context/ is named for a remote @context but exercises a cross-directory one. Across the whole corpus: 25 same-directory references, 6 cross-directory, and 0 true HTTP. So Resolver never opened a socket in any test.

That is a prerequisite rather than a tidy-up. Resolver's fetch, disk cache and offline=True refusal are exactly the layer #119 proposes moving onto referencing, 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_http starts a loopback ThreadingHTTPServer on an OS-assigned port, templates a schema and its remote @context into tmp_path, and runs the full pipeline with offline=False and an isolated cache_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_refused commits one disk-cache entry under tests/data/resolver_cache/ and asserts both halves of the offline guarantee: a warmed entry satisfies a fetch under offline=True, and a URL with no entry is refused. The filename is the sha256 digest Resolver._cache_file derives 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 of docs/maintaining-meta-schemas.md, which #123 is editing.

No production code changed

Resolver and DocumentLoader were exercisable as-is through the existing Options.cache_dir and offline parameters. That matters for #119: the tests describe the current retrieval contract from the outside, so they stay meaningful across the rewrite.

Verification

  • full suite: 561 passed, 9 skipped, against a measured baseline of 559 on main
  • make check: clean
  • uv run oold validate tests/data/oold --offline: PASS, 380 ok, 21 warnings, unchanged
  • parity against a fresh upstream clone: 6 passed
  • the HTTP test was deliberately broken once by pointing base_url at a closed port, and failed with a real connection refusal on context.remote, roundtrip.generated and context.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.

.gitattributes gains a -text rule for the new directory, so the committed cache entry keeps LF endings under Windows core.autocrlf.

- 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
@github-actions

Copy link
Copy Markdown
Contributor

Release preview

No version bump from the current commits (stays at v0.18.1). Use conventional commit types (feat, fix, ...) to trigger a release.

Changelog preview (truncated)

Preview via python-semantic-release and conventional commits.

@github-actions

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

Click to see benchmark comparison
📊 Benchmark Comparison (threshold: 1.3x)
============================================================

⚠️  Performance Regressions:
  ❌ test_core[v2]: 0.0435s → 0.0612s (+40.9%, ratio: 1.41x)

➖ Unchanged (within threshold):
  ➖ test_simple_dict_document_store: 0.0017s → 0.0017s (-0.0%)
  ➖ test_sqlite_document_store: 0.0019s → 0.0019s (-0.1%)
  ➖ test_local_sparql_store: 0.0395s → 0.0398s (+0.6%)
  ➖ test_oneof_subschema: 0.0593s → 0.0601s (+1.3%)
  ➖ test_enum_docstrings: 0.0502s → 0.0509s (+1.5%)
  ➖ test_subclass_inheritance: 0.0545s → 0.0542s (-0.5%)
  ➖ test_class_hierarchy: 0.0514s → 0.0521s (+1.4%)
  ➖ test_core[v1]: 0.0381s → 0.0388s (+1.7%)
  ➖ test_schema_generation[v1]: 0.0017s → 0.0017s (-0.4%)
  ➖ test_schema_generation[v2]: 0.0028s → 0.0028s (+1.1%)
  ➖ test_simple_json: 0.0007s → 0.0007s (+1.5%)
  ➖ test_complex_graph: 0.0016s → 0.0016s (+1.6%)

============================================================
Summary: 1 regressions, 0 improvements, 12 unchanged
============================================================

⚠️  Regressions detected but not failing build (informational only)

Threshold: 1.3x (30% slower triggers a regression warning)

Note: Benchmarks are informational only and won't fail the build.

💡 Tip: Download the benchmark-results artifact for detailed JSON data

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No fixture exercises a truly remote (HTTP) @context

2 participants