Skip to content

test(vis): xfail-pin pymat-surface repros for #220/#221/#222 - #224

Merged
gerchowl merged 2 commits into
mainfrom
tests/vis-bernhard-unit-repros
May 7, 2026
Merged

gerchowl merged 2 commits into
mainfrom
tests/vis-bernhard-unit-repros

Conversation

@gerchowl

@gerchowl gerchowl commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds tests/test_vis_bernhard_repros.py — 9 strict-xfail tests + 1 non-regression guard pinning the pymat-side half of Bernhard's mat-vis#311 / #313 feedback.

Relation to #219

#219 (test_substrate_repros.py) covers mat-vis#313 at the substrate / live-network level — Vis(...).to_threejs() must not raise against the real CDN. This PR adds pymat-surface unit-level coverage using mocked MatVisClient instances, so:

  • regressions in pymat's tier-resolution / repr / scalars accessor logic surface without network
  • the #220 and #221 issues (no upstream component) get coverage they don't currently have

Each xfail is strict=True — when a fix lands, the test XPASSes and CI fails until the marker is removed.

Test plan

Follow-up (post-merge, per-fix)

After each issue's fix lands: drop the corresponding xfail marker, then re-run Bernhard's literal repro from the originating mat-vis issue end-to-end (mat-vis#287/#288 lesson — don't trust unit tests alone for user-surface bugs).

Refs #220, #221, #222

gerchowl added 2 commits May 7, 2026 16:51
…strict xfails

Adds tests/test_vis_bernhard_repros.py covering the three pymat-side
issues filed from Bernhard's mat-vis#311 / #313 feedback:

* TestIssue220ScalarsAccessor: Vis.scalars accessor missing — three
  tests for attribute existence, authored-PBR after fetch, and lazy
  (no texture fetch).
* TestIssue221ReprObservability: pre-fetch repr shows fetched=False,
  post-fetch shows fetched=True with scalars/available_textures
  summary, and repr visibly differs across fetch.
* TestIssue222ScalarOnlySources: Vis("physicallybased", "Aluminum")
  must resolve tier→"scalar" automatically; .textures returns {};
  .to_threejs() succeeds. Plus a non-regression guard pinning
  textured-source default tier='1k' (kept outside the xfail class so
  it must keep passing today AND after the fix).

Complements the substrate-level live-network xfails in #219
(test_substrate_repros.py) — that file pins the upstream
mat-vis-client surface; this one pins the pymat Vis surface using
mocked clients so unit-level regressions surface without network.

Each xfail is strict: when the fix lands the test XPASSes and CI
fails until the marker is removed.

Refs #220, #221, #222
@gerchowl
gerchowl merged commit cb9c79d into main May 7, 2026
19 checks passed
gerchowl added a commit that referenced this pull request May 7, 2026
Vis('physicallybased', 'Aluminum').to_threejs() previously raised
MaterialNotStagedError because the substrate path treated
physicallybased like a textured source — tier defaulted to "1k"
which doesn't exist in physicallybased's manifest, so
fetch_all_textures raised before scalars could be read.

Three pieces:

1. **Type widening**: `tier: str = "1k"` → `tier: str | None = "1k"`
   matches the type already used in `set_identity` / `_validate_tier`.
   Setting `vis.tier = None` is a documented un-mapping operation
   (per `has_mapping` docstring).

2. **`__post_init__` auto-resolution** via new
   `_auto_resolve_tier_from_manifest()`. When source + material_id
   are set and the configured tier isn't in the source's manifest
   tier list, fall back to "scalar" if available. Permissive on
   client / manifest unavailability — mirrors `_validate_tier`'s
   policy. The default stays "1k" (textured-source majority);
   physicallybased silently re-resolves to "scalar".

3. **`_fetch` short-circuit**: when tier == "scalar", skip
   `client.fetch_all_textures` entirely and mark the Vis fetched
   with an empty texture dict. The scalars are already on the Vis
   (loaded from TOML or set explicitly); downstream adapters fall
   back to `Vis._PBR_DEFAULTS` for anything still None.

Closes the py-mat-side manifestation of mat-vis #313 — upstream
issue stays open for the substrate-path fix, but consumers no
longer hit the symptom because we route around it.

## Tests

- `tests/test_vis_bernhard_repros.py::TestIssue222ScalarOnlySources`
  (added in PR #224 as strict-xfail) flips to passing — drops the
  xfail marker.
- `tests/test_substrate_repros.py::TestMatVis313_PhysicallybasedAccess`
  (added in PR #219 as strict-xfail) also flips to passing as a
  cascade — drops the xfail, tightens the assertion to verify
  tier auto-resolution lands on "scalar" rather than just "doesn't
  raise."

Suite: 823 passed, 43 skipped, 15 xfailed (down from 17 — the two
that flipped were the #222 + #313 markers).

## Caller compatibility

- Existing `Vis(source="ambientcg", material_id="Wood095")` —
  unchanged. Auto-resolution sees "1k" is in ambientcg's tier
  list, leaves it alone.
- New `Vis(source="physicallybased", material_id="Aluminum")` —
  auto-resolves tier to "scalar"; `.to_threejs()` returns
  populated dict; `.textures` returns `{}`.
- Offline / cache-miss callers: auto-resolution silently skips
  rather than blocking construction.
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.

1 participant