Skip to content

No fixture exercises a truly remote (HTTP) @context #128

Description

@LukasOro

tests/data/oold/remote_context/ is named for a remote @context but exercises a cross-directory one. Counting every string @context and $ref in the corpus at b4e23ac:

Kind Count
same-directory sibling 25
cross-directory (..) 6
true HTTP (http://, https://) 0

The 6 cross-directory references are remote_context/Leaf.schema.json, broken/root_ref_not_reflected.schema.json, and four in broken/context_array_order_mismatch.schema.json.

So no fixture ever makes Resolver fetch a schema or a context over HTTP. That path is reached only by --meta remote, which fetches the meta-schemas rather than a document's @context, and by the opt-in parity tests.

Why it matters

  • context.remote is a FAIL-level check whose whole subject is a schema working as a remote context, and nothing in the corpus makes it remote.
  • Resolver's fetch, disk cache and offline=True refusal are exactly the layer Use referencing for resolve.py's URI and retrieval layer #119 proposes moving onto referencing. That refactor currently has no fixture touching retrieval, so a regression would pass CI.
  • The name misleads. A reader of remote_context/Leaf.schema.json reasonably concludes the remote path is covered.

The constraint that makes this a separate piece of work

A fixture that reaches the real network is not deterministic and cannot run in the offline CI matrix. Three shapes, cheapest last:

  1. Local HTTP server. A pytest fixture serving tests/data/oold/remote_context/ from http://127.0.0.1:<port>/, with the schema's @context pointed at that base when the fixture is built. Real socket, real Resolver retrieval path, no external dependency. The committed fixture cannot carry the URL, since the port varies, so the schema has to be templated or rewritten into tmp_path.
  2. Stub transport. Monkeypatch Resolver's retrieval hook to serve from disk under an https:// URL. Deterministic and small, but it skips the code under test, which is the retrieval itself.
  3. Warm cache. Commit a cache entry keyed by an https:// URL and run with offline=True, asserting the cached document resolves and that a missing one is refused with the offline message. Tests the cache and the refusal, not the fetch.

1 and 3 are complementary rather than alternatives: 3 covers the offline guarantee the vendored meta-schemas depend on, 1 covers the fetch. 2 is worth having only if 1 turns out to be flaky in CI.

Also

Either rename remote_context/ to say cross-directory, or give it a genuinely remote sibling so the name is true. Renaming touches tests/test_validation/conftest.py's fixture and docs/maintaining-meta-schemas.md.

Raised in review of #114 (#114 (comment)).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions