Skip to content

Make unit tests run offline and add HTTP request timeouts - #225

Open
tejasng053 wants to merge 1 commit into
aboutcode-org:masterfrom
tejasng053:fix/offline-tests-timeouts-188
Open

tejasng053 wants to merge 1 commit into
aboutcode-org:masterfrom
tejasng053:fix/offline-tests-timeouts-188

Conversation

@tejasng053

Copy link
Copy Markdown

What's changed?

Three unit tests make live requests to pub.dev or CocoaPods, so offline runs fail and network problems can stall the suite. The CocoaPods tests mock the utility module's get_response, but miss the separately imported reference in fetchcode.package.

Mock those missing calls using the existing podspec fixtures, mock the pub.dev existence check, and add an automatic fixture that fails unexpected HTTP requests. The package parsing and expected results still run unchanged.

Also apply a shared 30-second timeout to all seven direct Requests calls in FetchCode's download and metadata helpers, as requested in the issue. This bounds connection setup and read inactivity, not total download duration. Add 21 regression cases covering timeout arguments, response decoding, error propagation, and preservation of an existing file after a timed-out download. Document the behavior and update the changelog.

Related issue

Fixes #188

Verification before publication

  • Reproduced on upstream ffbd683: blocking HTTP requests produced 3 failures and 153 passes, identifying the pub.dev test and both CocoaPods tests.
  • Before the implementation, the new focused checks produced 13 failures and 11 passes: missing timeout arguments and the three live requests.
  • After the fix, all 177 tests passed, with no skips or exclusions, while DNS lookups and socket connections were additionally blocked during the run.
  • make check passed: pycodestyle, isort, and Black.
  • git diff --check and a review of all seven direct Requests call sites passed.
  • Tested locally with Python 3.12.3 on Linux. One existing chardet deprecation warning remains. Other Python versions and remote CI have not yet been verified.

Checklist

  • I understand the problem and implemented the solution using appropriate functions.
  • I added or updated tests to cover my changes.
  • I verified my changes by running linting, ensuring all local tests pass, and confirming that CI checks succeed.

The last checkbox awaits remote CI; all local checks above passed. Prepared with Codex assistance, with the implementation and complete diff reviewed before publication.

Fixes aboutcode-org#188

Signed-off-by: tejasng053 <tejasng053@gmail.com>

This branch has not been deployed

No deployments
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.

Some unit tests depends on external services

1 participant