Skip to content

test: isolate deprecation unit test from live NASA URS calls#1370

Open
mvanhorn wants to merge 1 commit into
earthaccess-dev:mainfrom
mvanhorn:fix/1321-mock-nasa-unit-test
Open

test: isolate deprecation unit test from live NASA URS calls#1370
mvanhorn wants to merge 1 commit into
earthaccess-dev:mainfrom
mvanhorn:fix/1321-mock-nasa-unit-test

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Description

tests/unit/test_deprecations.py made real network calls to NASA's URS login endpoint. Its auth fixture mocked the URS calls only while constructing the auth object, but the responses context exited before the test body ran, so earthaccess.login(...) and Store(auth) inside the test reached the live service. That makes a "unit" test depend on network access and valid credentials, so it fails or hangs in offline/CI sandboxes.

This keeps the mocked URS responses active for the whole test by making the auth fixture yield from inside a function-scoped responses.RequestsMock context. Every request on the login/Store path is now served by the mock, and any unmocked request is blocked rather than sent to NASA. The test's assertions are unchanged; only its network isolation is fixed. No production code changes.

resolves #1321


"Ready for review" checklist

  • Place this Pull Request (PR) in draft until it is ready for review (see below)
  • Please review our Pull Request Guide
  • Mark "ready for review" after following instructions in the guide

Merge checklist

  • PR title is descriptive
  • PR body contains links to related and resolved issues (e.g. closes #1)
  • If needed, CHANGELOG.md updated (not needed — test-only change, no user-facing behavior change)
  • If needed, docs and/or README.md updated (not needed)
  • If needed, unit tests added (unsure how? see below!) (this PR repairs the existing unit test's network isolation)
  • All checks passing (tip: comment pre-commit.ci autofix if pre-commit is failing) (pytest tests/unit/test_deprecations.py passes locally with no network)
  • At least one approval

📚 Documentation preview 📚: https://earthaccess--1370.org.readthedocs.build/en/1370/

@github-actions

Copy link
Copy Markdown

Binder 👈 Launch a binder notebook on this branch for commit f248c0b

I will automatically update this comment whenever this PR is modified

@Sherwin-14 Sherwin-14 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.

Thanks @mvanhorn! This looks so much cleaner now.

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.

Unit tests can fail from connectivity issues to NASA services

2 participants