-
Notifications
You must be signed in to change notification settings - Fork 0
Add GitHub-issue-driven test framework (+ src/ library carve-out) #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gaurav
wants to merge
132
commits into
main
Choose a base branch
from
add-github-issue-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
132 commits
Select commit
Hold shift + click to select a range
06857d5
Moved TestRow into its own file.
gaurav a0325b6
Added /.env to .gitignore.
gaurav 0009dc0
Implemented basic GitHub issue testing (but it doesn't work at all).
gaurav f297735
Check for a GitHub Authentication Token.
gaurav 9b96675
Add support for `--issue` to specify one or more GitHub issues to check.
gaurav 97bb7a6
Cleaned up some code.
gaurav ed8f1db
Sped up tests, made things work better.
gaurav f0342ce
Fixed some issues.
gaurav ebac7ab
It works! But it shouldn't. Cross that bridge later etc.
gaurav 05b767e
Various improvements.
gaurav 15b28d1
Various improvements.
gaurav a6845a3
Got rid of xfail system (too much bother).
gaurav 54001bb
Incorporated issue state into outputs.
gaurav 150f4a6
Better?
gaurav 92821bf
Nope, still too messy.
gaurav 9a4a22c
Added some NameRes tests.
gaurav 2a610a4
Merge branch 'main' into add-github-issue-tests
gaurav 0848de4
Reorganized test files.
gaurav 127cca1
Don't need __init__.py in top-level src directory.
gaurav b7d2786
Merge branch 'main' into add-github-issue-tests
gaurav b91609f
Moved NodeNorm/NameRes into own files.
gaurav 8a08e9a
Moved sources into separate directories.
gaurav 1f84aea
Updated CLAUDE.md in line with updated code.
gaurav 31b4436
Claude suggested moving blocklist code into src/ so we did.
gaurav 6b60325
Added blocklist.py where a lot of the blocklist code has moved.
gaurav ac41e08
Refactor GitHub issue assertions into a dedicated package.
gaurav ffbc70f
Use pytest subtests for GitHub issue tests so all assertions run inde…
gaurav 1524b27
Avoid slow GitHub API calls when building issue IDs.
gaurav 9a19e45
Cleaned up some Claude code.
gaurav 0ec9e20
Refactor assertions into a proper framework for easy authoring
gaurav ddaa14f
Auto-generate assertions/README.md from handler class attributes
gaurav 4ed6091
Speed up GitHub issues test collection with pytest_generate_tests hook
gaurav c63e2d1
Parallelize GitHub issues tests with pytest-xdist
gaurav 75abe00
Cache Google Sheet CSV to disk so xdist workers share one download
gaurav 3bf169e
Fix non-deterministic test ordering under pytest-xdist
gaurav 93753b0
Cleaned up code a bit.
gaurav 2e3b93a
Improved outputs.
gaurav db7933b
Always download fresh Google Sheet data on each test run
gaurav 768cf91
xfail open GitHub issues so failures don't block CI
gaurav 6ee7441
Wipe GitHub issues cache at the start of every test run
gaurav 74c5e35
Add system tests for invalid BabelTest assertion name detection
gaurav 33aa773
Report failing subtests of open issues as XFAIL instead of FAIL
gaurav d238f38
Improved outputs.
gaurav 8807972
Speed up GitHub issues test collection via Search API
gaurav 056e168
Fail hard on unknown assertion types instead of XFAIL
gaurav 79fab58
Removed default repo list.
gaurav fc158e4
Add DoesNotResolveWith assertion handler
gaurav 4b77e98
Fixed Claude typo.
gaurav d3fb921
Improve error message.
gaurav 4d272f1
Add HasLabel assertion handler
gaurav a9c0842
Fixed typo in my code.
gaurav 4b6ea91
XPASS tests now correctly complain.
gaurav 91782a2
Merge branch 'main' into add-github-issue-tests
gaurav 8414350
Regenerated BabelTest assertions documentation.
gaurav 1c75b08
Fixed timeout.
gaurav 3eeeccf
Add unit test marker and GitHub Actions workflow for PRs
gaurav bccde07
Potential fix for pull request finding
gaurav f733858
Potential fix for pull request finding
gaurav 79c01f7
Potential fix for pull request finding
gaurav 9163671
Potential fix for pull request finding
gaurav 79a0b5c
Potential fix for pull request finding
gaurav 8e90722
Potential fix for pull request finding
gaurav 4a399e6
Potential fix for pull request finding
gaurav 224cd42
Fix CURIE prewarming to only normalize CURIE parameters
gaurav 2628f50
Potential fix for pull request finding
gaurav 32248b2
Move pytest marker config from pyproject.toml to tests/pytest.ini
gaurav c175f67
Tweaked error message.
gaurav 1db38aa
Simplify: remove dead code and minor cleanup
gaurav 2251884
Handle corrupted GitHub issues cache file gracefully
gaurav 90bc845
Replace print() with debug logging in SearchByNameHandler
gaurav d474b18
Potential fix for pull request finding
gaurav 14d230c
Fixed comment.
gaurav ae9ed8d
Move pytest config from tests/pytest.ini to pyproject.toml
gaurav dc51c0b
Updated pytest to 9.0+ so we can use subtests.
gaurav 552d53a
Move GitHub repo list from conftest.py to targets.ini [DEFAULT]
gaurav 2de6e09
Updated uv.lock.
gaurav 870f1f9
Document param_set/param_sets terminology across assertions package
gaurav d6077ea
Reject extra params in HasLabel and SearchByName assertions
gaurav d7fde85
Add unit test documenting yaml.YAMLError on malformed YAML block
gaurav 688ef36
Add TestEmptyOrNullBabelTests to document current behaviour for empty…
gaurav a029093
Add unit tests for issue_has_tests() and get_issues_with_tests()
gaurav fd44d66
Simplify: remove dead code, fix string parsing, rename fixture
gaurav 0c46ce9
Handle missing labels in NodeNorm.
gaurav aa94099
Fixed level lookup in NodeNorm result.
gaurav ab72ae4
Merge branch 'main' into add-github-issue-tests
gaurav 4f74880
Reverted NameRes to Solr instead of ElasticSearch.
gaurav 714d4bb
Reconfigured ci-es.
gaurav 1e9c42f
Changed Biolink Type param to a list.
gaurav 5ee0efa
Add csv-to-babeltests CLI for converting CSV assets into BabelTests Y…
gaurav 6d5d593
Add pytest-subtests dependency
gaurav b0a4dc0
Add request timeouts and fix bulk_lookup error message
gaurav 65236d6
Validate Google Sheet HTTP response before caching
gaurav 5150703
Fix wiki syntax parsing: allow assertion-name-only and warn on unreso…
gaurav da94577
Clean up lock files on pytest startup and fix incomplete comment
gaurav 37d1da6
Fix CI unit-test workflow: restrict paths and inject GITHUB_TOKEN
gaurav f125cd5
Move curie_params overrides after class attributes in assertion handlers
gaurav 7eeafde
Fix param-aware cache keys in CachedNodeNorm and CachedNameRes
gaurav e8c4e6f
Improve robustness of GitHub issue parsing and fetching
gaurav f6088ad
Fix GitHub issues test harness: lazy dotenv, xfail clarity, missing _…
gaurav b7146b8
Fix two bugs surfaced by Copilot review
gaurav 576fa0f
Fix unbounded logger growth in GitHubIssueTest
gaurav 999240f
Merge branch 'add-github-issue-tests' of github.com:TranslatorSRI/bab…
gaurav be3c09b
Fixed endpoint for NameRes blocklist.
gaurav 4250f15
Fix four issues from Opus code review of PR #67
gaurav e808947
Catch expired GitHub token and fail only the GitHub issue tests
gaurav 39e4e0e
Fix bugs and clean up code quality from simplify review
gaurav 692418a
Fix three bugs identified in PR #67 review
gaurav 09f9a84
Potential fix for pull request finding
gaurav d873d4a
Removed unused import.
gaurav bbba0d9
Removed unused import.
gaurav 27e45ec
Potential fix for pull request finding
gaurav a329eb0
Add test documenting YAML scalar assertion param handling
gaurav 52ef896
Merge main into add-github-issue-tests, resolving blocklist conflicts
gaurav 063975d
Simplify assertion loop logic and YAML param normalization
gaurav e36334f
Simplify test config cleanup and GitHub issue caching
gaurav e1ee783
Keep open-issue assertion failures inside the xfail family
gaurav adb7829
Make the {{BabelTest|...}} wiki marker case-insensitive
gaurav 03e0c6b
Run GitHub-issue unit tests without a GITHUB_TOKEN
gaurav e322040
Validate CURIEs before warming the NodeNorm cache
gaurav a9ec8e4
Expire the Google Sheet CSV cache after an hour
gaurav 7e58ba7
Limit bare pytest collection to the tests directory
gaurav af19a1e
Correct Repositories comment in targets.ini
gaurav 0a20287
Skip GitHub issue fetch when -m deselects the test
gaurav 2a3085a
Enforce 2+ CURIE arity in ResolvesWith/DoesNotResolveWith
gaurav f0c6cb8
Avoid KeyError in normalize_curie if NodeNorm omits a CURIE
gaurav c7b9da9
Wire SearchByName top-N from targets.ini NameResXFailIfInTop
gaurav 24ed4f4
Extract deselected_by_markexpr into a shared helper
gaurav e983020
Defer Google Sheet downloads so -m unit stays offline
gaurav d71ae23
Validate babel_tests YAML shape with clear errors
gaurav add0848
Guard against empty NodeNorm type list in assertion messages
gaurav c0ddd7b
Use a module-local YAML dumper in csv_to_babeltests
gaurav 1adf194
Document testing/repo gotchas in CLAUDE.md
gaurav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| name: Tests | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| unit-tests: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: astral-sh/setup-uv@v6 | ||
|
|
||
| - name: Run unit tests | ||
| env: | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| run: uv run pytest -m unit -v | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| # Ignore the root .env file. | ||
| /.env | ||
|
|
||
| # Ignore all data files. | ||
| data/ | ||
|
|
||
|
|
||
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
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
File renamed without changes.
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,243 @@ | ||
| <!-- AUTO-GENERATED — do not edit by hand. | ||
| Regenerate with: uv run python -m src.babel_validation.assertions.gen_docs --> | ||
|
|
||
| # BabelTest Assertion Types | ||
|
|
||
| This package defines the assertion types that can be embedded in GitHub issue bodies and evaluated against the NodeNorm and NameRes services. | ||
|
|
||
| ## Embedding Tests in Issues | ||
|
|
||
| Two syntaxes are supported: | ||
|
|
||
| **Wiki syntax** (one assertion per line): | ||
| ``` | ||
| {{BabelTest|AssertionType|param1|param2|...}} | ||
| ``` | ||
|
|
||
| **YAML syntax** (multiple assertions, multiple param sets): | ||
| ```` | ||
| ```yaml | ||
| babel_tests: | ||
| AssertionType: | ||
| - param1 | ||
| - [param1, param2] | ||
| ``` | ||
| ```` | ||
|
|
||
| Assertion names are case-insensitive, as is the `{{BabelTest|...}}` marker itself. | ||
|
|
||
| ## Param Sets | ||
|
|
||
| Each assertion can be invoked with one or more **param sets** — independent groups of | ||
| parameters that are each evaluated separately. | ||
|
|
||
| - **Wiki syntax** — each `{{BabelTest|...}}` line is one param set. | ||
| - **YAML syntax** — each list entry under an assertion key is one param set; a bare string | ||
| is a single-element param set, a YAML list is a multi-element param set. | ||
|
|
||
| The meaning of each element in a param set depends on the assertion type (see below). | ||
| For most assertions the elements are CURIEs; for `HasLabel` the second element is a | ||
| label string; for `ResolvesWithType` the first element is a Biolink type. | ||
|
|
||
| --- | ||
|
|
||
| ## NodeNorm Assertions | ||
|
|
||
| These assertions test the [NodeNorm](https://nodenorm.transltr.io/docs) service. | ||
|
|
||
| ### Resolves | ||
|
|
||
| **Applies to:** NodeNorm | ||
|
|
||
| Each CURIE in each param_set must resolve to a non-null result in NodeNorm. | ||
|
|
||
| **Parameters:** One or more CURIEs per param_set. | ||
|
|
||
| **Wiki syntax:** | ||
| ``` | ||
| {{BabelTest|Resolves|CHEBI:15365}} | ||
| {{BabelTest|Resolves|MONDO:0005015|DOID:9351}} | ||
| ``` | ||
|
|
||
| **YAML syntax:** | ||
| ```yaml | ||
| babel_tests: | ||
| Resolves: | ||
| - CHEBI:15365 | ||
| - [MONDO:0005015, DOID:9351] | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### DoesNotResolve | ||
|
|
||
| **Applies to:** NodeNorm | ||
|
|
||
| Each CURIE in each param_set must fail to resolve (return null) in NodeNorm. Use this to confirm that an identifier is intentionally not normalizable. | ||
|
|
||
| **Parameters:** One or more CURIEs per param_set. | ||
|
|
||
| **Wiki syntax:** | ||
| ``` | ||
| {{BabelTest|DoesNotResolve|FAKENS:99999}} | ||
| ``` | ||
|
|
||
| **YAML syntax:** | ||
| ```yaml | ||
| babel_tests: | ||
| DoesNotResolve: | ||
| - FAKENS:99999 | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### ResolvesWith | ||
|
|
||
| **Applies to:** NodeNorm | ||
|
|
||
| All CURIEs within each param_set must resolve to the identical normalized result. Use this to assert that two identifiers are equivalent. | ||
|
|
||
| **Parameters:** Two or more CURIEs per param_set. All must resolve to the same result. | ||
|
|
||
| **Wiki syntax:** | ||
| ``` | ||
| {{BabelTest|ResolvesWith|CHEBI:15365|PUBCHEM.COMPOUND:1}} | ||
| ``` | ||
|
|
||
| **YAML syntax:** | ||
| ```yaml | ||
| babel_tests: | ||
| ResolvesWith: | ||
| - [CHEBI:15365, PUBCHEM.COMPOUND:1] | ||
| - [MONDO:0005015, DOID:9351] | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### DoesNotResolveWith | ||
|
|
||
| **Applies to:** NodeNorm | ||
|
|
||
| The CURIEs within each param_set must NOT all resolve to the same normalized result. Use this to assert that two identifiers are intentionally distinct entities. | ||
|
|
||
| **Parameters:** Two or more CURIEs per param_set. They must not all resolve to the same result. | ||
|
|
||
| **Wiki syntax:** | ||
| ``` | ||
| {{BabelTest|DoesNotResolveWith|CHEBI:15365|CHEBI:16856}} | ||
| ``` | ||
|
|
||
| **YAML syntax:** | ||
| ```yaml | ||
| babel_tests: | ||
| DoesNotResolveWith: | ||
| - [CHEBI:15365, CHEBI:16856] | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### HasLabel | ||
|
|
||
| **Applies to:** NodeNorm | ||
|
|
||
| The CURIE must resolve in NodeNorm and its primary label (id.label) must match the expected label exactly (case-sensitive). | ||
|
|
||
| **Parameters:** Exactly two elements per param_set: a CURIE, then the expected label string. | ||
|
|
||
| **Wiki syntax:** | ||
| ``` | ||
| {{BabelTest|HasLabel|CHEBI:15365|aspirin}} | ||
| ``` | ||
|
|
||
| **YAML syntax:** | ||
| ```yaml | ||
| babel_tests: | ||
| HasLabel: | ||
| - [CHEBI:15365, aspirin] | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### ResolvesWithType | ||
|
|
||
| **Applies to:** NodeNorm | ||
|
|
||
| Each param_set must have at least two elements: the first is the expected Biolink type (e.g. 'biolink:Gene'), and the remainder are CURIEs that must resolve with that type. | ||
|
|
||
| **Parameters:** Each param_set: first element is the expected Biolink type (e.g. `biolink:Gene`), remaining elements are CURIEs. | ||
|
|
||
| **Wiki syntax:** | ||
| ``` | ||
| {{BabelTest|ResolvesWithType|biolink:Gene|NCBIGene:1}} | ||
| ``` | ||
|
|
||
| **YAML syntax:** | ||
| ```yaml | ||
| babel_tests: | ||
| ResolvesWithType: | ||
| - [biolink:Gene, NCBIGene:1, HGNC:5] | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## NameRes Assertions | ||
|
|
||
| These assertions test the [NameRes](https://name-lookup.transltr.io/docs) service. | ||
|
|
||
| ### SearchByName | ||
|
|
||
| **Applies to:** NameRes | ||
|
|
||
| Each param_set must have at least two elements: a search query string and an expected CURIE. The test passes if the CURIE's normalized identifier appears within the top N results (default N=5) when NameRes looks up the search query. | ||
|
|
||
| **Parameters:** Each param_set: the **search query string** and the **expected CURIE**. The CURIE is normalized via NodeNorm (drug/chemical conflation enabled) before matching. | ||
|
|
||
| **Wiki syntax:** | ||
| ``` | ||
| {{BabelTest|SearchByName|water|CHEBI:15377}} | ||
| ``` | ||
|
|
||
| **YAML syntax:** | ||
| ```yaml | ||
| babel_tests: | ||
| SearchByName: | ||
| - [water, CHEBI:15377] | ||
| - [diabetes, MONDO:0005015] | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Special Assertions | ||
|
|
||
| ### Needed | ||
|
|
||
| **Applies to:** NodeNorm and NameRes | ||
|
|
||
| Marks an issue as needing a test — always fails as a reminder to add real assertions. | ||
|
|
||
| **Wiki syntax:** | ||
| ``` | ||
| {{BabelTest|Needed}} | ||
| ``` | ||
|
|
||
| **YAML syntax:** | ||
| ```yaml | ||
| babel_tests: | ||
| Needed: | ||
| - placeholder | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Adding a New Assertion Type | ||
|
|
||
| 1. Choose the right module: | ||
| - `nodenorm.py` — for NodeNorm-only assertions (subclass `NodeNormTest`, override `test_param_set`) | ||
| - `nameres.py` — for NameRes-only assertions (subclass `NameResTest`, override `test_param_set`) | ||
| - `common.py` — for assertions that apply to both services (subclass `AssertionHandler`, override `test_with_nodenorm` and/or `test_with_nameres`) | ||
|
|
||
| 2. Define the class with `NAME`, `DESCRIPTION`, `PARAMETERS`, `WIKI_EXAMPLES`, `YAML_PARAMS`, and `test_param_set()` (or both `test_with_*` methods for `AssertionHandler` subclasses). | ||
|
|
||
| 3. Import it in `__init__.py` and add an instance to `ASSERTION_HANDLERS`. | ||
|
|
||
| 4. Run `uv run python -m src.babel_validation.assertions.gen_docs` to regenerate `README.md`. |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.