Skip to content

Assertions framework for BabelTest expectations (2/4)#102

Open
gaurav wants to merge 4 commits into
mainfrom
split/2-assertions
Open

Assertions framework for BabelTest expectations (2/4)#102
gaurav wants to merge 4 commits into
mainfrom
split/2-assertions

Conversation

@gaurav

@gaurav gaurav commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Stack 2 of 4 splitting #67. Base: split/1-library-reorg (PR #101) — review/merge that first.

Adds src/babel_validation/assertions: the engine that turns a named BabelTest assertion + its parameters into a check evaluated against NodeNorm/NameRes.

What changes

  • Handler classes for HasLabel, SearchByName, ResolvesWith, DoesNotResolveWith, ResolvesWithType, Needed, … each declaring its params and producing a TestResult.
  • gen_docs.py generates assertions/README.md from the handler class attributes; tests/test_environment/test_assertions_docs.py (offline, unit) asserts the checked-in README stays in sync.
  • Registers the unit pytest marker (first used by that test).

Depends only on PR #101's core + services — no GitHub/network code here.

Verify

  • uv run pytest -m unit -q → assertions docs test passes offline.
  • uv run python -m src.babel_validation.assertions.gen_docs reproduces the committed README.

🤖 Generated with Claude Code

Introduce src/babel_validation/assertions: a small framework of handler
classes that turn a named BabelTest assertion (HasLabel, SearchByName,
ResolvesWith, DoesNotResolveWith, ResolvesWithType, Needed, ...) plus its
parameters into a check evaluated against NodeNorm/NameRes, returning a
TestResult. assertions/README.md is generated from the handler class
attributes by gen_docs.py, and test_assertions_docs.py (marked `unit`,
offline) asserts the checked-in README stays in sync. Register the `unit`
marker, first used by that test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

gaurav and others added 2 commits June 26, 2026 14:57
…path

- ResolvesWithTypeHandler: use node.get('type') or [] instead of node['type']
  to match the existing first_type() guard (NodeNorm can return results without
  a type key)
- NeededHandler: add test_with_nameres override so Needed issues fail on both
  NodeNorm and NameRes paths, not just NodeNorm

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove drug_chemical_conflate='true' from the NodeNorm call used to
  canonicalize the expected CURIE; NameRes normalizes without conflation, so
  using it caused structural false failures for drug/chemical CURIEs
- Use .get('label', '') instead of ['label'] to avoid KeyError for CURIEs
  that NodeNorm resolves without a preferred label
- Regenerate assertions/README.md to reflect the updated parameter description

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comment thread src/babel_validation/assertions/nameres.py
Comment thread src/babel_validation/assertions/__init__.py Outdated
Comment thread src/babel_validation/assertions/__init__.py Outdated
…ionHandler

- AssertionHandler.test_with_nodenorm/test_with_nameres: return iter([]) instead
  of [] to match the Iterator[TestResult] annotation; simplify docstrings to
  remove reference to github_issues_test_cases.py (module not yet in this PR)
- Remove same stale reference from NodeNormTest.test_param_set and
  NameResTest.test_param_set docstrings
- SearchByNameHandler.DESCRIPTION: "exactly two" not "at least two" to match
  the len(params) != 2 enforcement in test_param_set
- Regenerate assertions/README.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

2 participants