Skip to content

fix(test): make Test_scitag.py independent of the live scitags.org API (backport to rel-v9r0) - #9004

Merged
aldbr merged 1 commit into
DIRACGrid:rel-v9r0from
fstagni:fix/scitag-flaky-tests-rel-v9r0
Dec 4, 2026
Merged

aldbr merged 1 commit into
DIRACGrid:rel-v9r0from
fstagni:fix/scitag-flaky-tests-rel-v9r0

Conversation

@fstagni

@fstagni fstagni commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

BEGIN_PR_BODY

Description

Backport of #9003 to rel-v9r0.

The scitag unit tests were failing in CI (e.g. this run) because get_scitag() resolves VO/activity ids from the live https://scitags.org/api.json, while the tests asserted against ids hardcoded from a past snapshot of that API:

  • atlas Analysis Output is now activityId=12 upstream (test expected 18) → assert 140 == 146
  • atlas Debug no longer matches (test expected 9) → falls back to default → assert 129 == 137
  • any transient failure of the HTTP fetch also silently falls back to defaults, making the tests depend on network availability.

This PR makes the tests hermetic:

  • requests.get is mocked with a static fixture mirroring the api.json structure, so results are deterministic.
  • the module-level TTL caches (_scitag_cache, _scitag_json_cache) are cleared around each test so cached real-network results cannot leak into the tests.
  • two tests are added covering the network-failure fallback to defaults, and that the API is fetched at most once (cache behaviour).

The suite now runs in <1s with no network access.

Local tests (with ANA eras)

  • TESTDIRAC: Unit tests

END_PR_BODY

get_scitag() fetches https://scitags.org/api.json, but the unit tests
asserted against VO/activity ids hardcoded from a past snapshot of that
API. scitags.org has since evolved (e.g. atlas 'Analysis Output' moved
from activityId 18 to 12, 'Debug' no longer matches), and the fetch can
also fail outright in CI, so the tests were flaky.

Mock the network call with a static fixture, clear the module-level
caches around each test, and add coverage for the network-failure
fallback and the fetch-once caching behaviour.
@aldbr
aldbr merged commit 7d8cdac into DIRACGrid:rel-v9r0 Dec 4, 2026
32 of 34 checks passed
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