Skip to content

Fix #481: make tests of Pubchem more robust#1219

Merged
mhucka merged 15 commits intomainfrom
mh-revised-fix-481
Mar 26, 2026
Merged

Fix #481: make tests of Pubchem more robust#1219
mhucka merged 15 commits intomainfrom
mh-revised-fix-481

Conversation

@mhucka
Copy link
Contributor

@mhucka mhucka commented Mar 12, 2026

This implements a recommendation from Pavol Juhas on PR #1113 about using mocking to avoid flaky test behavior in pubchem_test.py.

In order to avoid failures in CI, this follows a [recommendation from
Pavol Juhas on PR #1113](
#1113 (review))
about using mocking to avoid flaky test behavior in `pubchem_test.py`.
@mhucka mhucka force-pushed the mh-revised-fix-481 branch from 1b9ad4c to 70ddda8 Compare March 12, 2026 22:25
@mhucka mhucka added the area/dependencies Involves packages or other software that qsim depends on label Mar 13, 2026
@mhucka mhucka self-assigned this Mar 13, 2026
@mhucka mhucka linked an issue Mar 13, 2026 that may be closed by this pull request
@mhucka mhucka added the area/health Involves code and/or project health label Mar 13, 2026
@mhucka mhucka requested a review from pavoljuhas March 13, 2026 21:21
@mhucka mhucka changed the title Fix #481: add mocking of Pubchem network calls Update pubchem interface and fix #481 Mar 13, 2026
@mhucka
Copy link
Contributor Author

mhucka commented Mar 13, 2026

/gemini review

@mhucka mhucka enabled auto-merge March 13, 2026 22:15
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the PubChem interface to be compatible with a new version of the pubchempy library and improves the test suite by using mocking to avoid flaky tests. The changes are well-implemented. I've added a few suggestions to further improve the robustness of the API call retry mechanism and the structure of the test suite.

@mhucka mhucka marked this pull request as draft March 14, 2026 02:13
auto-merge was automatically disabled March 14, 2026 02:13

Pull request was converted to draft

@mhucka mhucka force-pushed the mh-revised-fix-481 branch from dda1837 to 1b8114b Compare March 14, 2026 04:02
@mhucka mhucka marked this pull request as ready for review March 14, 2026 04:42
@mhucka mhucka enabled auto-merge March 14, 2026 04:42
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the tests for the PubChem interface to use mocking, which resolves flakiness by avoiding calls to the live API in unit tests. It also introduces a new integration test for the live API, complete with a retry mechanism to improve robustness. The changes are well-structured and the new tests are thorough. I've identified some redundant try-except ImportError blocks in the new test methods. Since the test class is already skipped if pubchempy is not available, these blocks are unnecessary and can be removed or simplified for better code clarity.

mhucka added 4 commits March 14, 2026 05:26
Gemini Code Assist is right; they're not needed.
This is test code. This just doesn't seem worth doing more.
@mhucka mhucka changed the title Update pubchem interface and fix #481 Update Pubchem interface and fix #481 Mar 16, 2026
@mhucka mhucka changed the title Update Pubchem interface and fix #481 Fix #481: make tests of Pubchem more robust Mar 16, 2026
Copy link
Contributor

@pavoljuhas pavoljuhas left a comment

Choose a reason for hiding this comment

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

For now let us avoid implementing retries for a test that is not selected.

If it is a problem later we can use the pytest-retry plugin for that one test instead.

Otherwise LGTM.

mhucka added 6 commits March 25, 2026 22:29
Per review comments, removing the retry code.
This is the result of running the pip-compile script, to account for the
addition of `pytest-retry` to `dev_tools/requirements/deps/pytest.txt`.
@mhucka mhucka requested a review from pavoljuhas March 26, 2026 05:40
auto-merge was automatically disabled March 26, 2026 22:10

Merge commits are not allowed on this repository

@mhucka mhucka merged commit e5ea36b into main Mar 26, 2026
28 checks passed
@mhucka mhucka deleted the mh-revised-fix-481 branch March 26, 2026 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dependencies Involves packages or other software that qsim depends on area/health Involves code and/or project health

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests flaky due to dependency on network

2 participants