Skip to content

test: simplify canonized-prochirality cache transfer test - #240

Merged
targos merged 3 commits into
mainfrom
simplify-prochirality-cache-test
Jun 29, 2026
Merged

test: simplify canonized-prochirality cache transfer test#240
targos merged 3 commits into
mainfrom
simplify-prochirality-cache-test

Conversation

@lpatiny

@lpatiny lpatiny commented Jun 29, 2026

Copy link
Copy Markdown
Member

Simplifies the canonizedProchiralities is transferred across TopicMolecule instances test.

It previously monkey-patched OpenChemLib's ensureHelperArrays to count CIP recomputations as an indirect proxy for "the cache was reused". Since fromMolecule transfers the cache entry by reference, the test now asserts that reference equality directly (reused.cache.prochiralityByEnantioID is the same object as the original) plus that the resulting labels are still correct. No spy, no try/finally restore, no coupling to OCL internals.

Assert the transferred cache entry directly (reference equality on
`prochiralityByEnantioID`) instead of monkey-patching OCL's
`ensureHelperArrays` to count CIP recomputations. The shared reference is
the optimisation, so this tests intent directly and drops the spy, the
try/finally restore, and coupling to OCL internals.
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.92%. Comparing base (92405cb) to head (7a95ca5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #240   +/-   ##
=======================================
  Coverage   90.92%   90.92%           
=======================================
  Files          94       94           
  Lines        2743     2743           
  Branches      704      704           
=======================================
  Hits         2494     2494           
  Misses        226      226           
  Partials       23       23           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lpatiny

lpatiny commented Jun 29, 2026

Copy link
Copy Markdown
Member Author

@targos Is the the correct way ? it is not clear to me if we need to mockRestore: https://vitest.dev/api/mock.html

@targos

targos commented Jun 29, 2026

Copy link
Copy Markdown
Member

I don't understand. The description says that spying is no longer necessary, but it's still there.

mockRestore is correct. I was suggesting to use the using ... syntax for automatic cleanup but that's ok too.

@targos

targos commented Jun 29, 2026

Copy link
Copy Markdown
Member

Note that there is another test with manual spy in the project

@lpatiny

lpatiny commented Jun 29, 2026

Copy link
Copy Markdown
Member Author

Yes I first removed the spying but then thought that it is an interesting way to spy the ensureHelper and that actually it is complementary. So I added it again (this is why there are 2 commits)

Assisted-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@targos
targos merged commit 7ee7af7 into main Jun 29, 2026
10 checks passed
@targos
targos deleted the simplify-prochirality-cache-test branch June 29, 2026 13:56
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