Skip to content

test: mock network calls in test_retrieve#41

Merged
rilma merged 3 commits intofeatures/upgrade-ci-cdfrom
copilot/sub-pr-40
Feb 21, 2026
Merged

test: mock network calls in test_retrieve#41
rilma merged 3 commits intofeatures/upgrade-ci-cdfrom
copilot/sub-pr-40

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 21, 2026

test_retrieve was hitting real external URLs (irimodel.org, chain-project.net), making the test suite flaky, slow, and broken in restricted CI environments.

Changes

  • Mock wget.download via unittest.mock.patch so no network I/O occurs
  • Tarball cases (00_iri.tar, 00_ccir-ursi.tar): create a minimal in-memory tar fixture using io.BytesIO + tarfile, exercising the full extract-and-delete path in update.retrieve
  • Plain-file cases (apf107.dat, ig_rz.dat): write a local stub file, exercising the non-tar path
  • Isolated temp dirs: each parameterized case gets its own TemporaryDirectory instead of sharing one across the class
  • Call assertion: verify wget.download receives the correct f"{url}/{filename}" and out arguments
with patch("pyiri2016.api.update.wget.download", return_value=fake_path) as mock_download:
    update.retrieve(url, filename, directory=tmpdir)
    mock_download.assert_called_once_with(
        f"{url}/{filename}", out=tmpdir, bar=ANY
    )

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 21, 2026 21:00
Co-authored-by: rilma <14822065+rilma@users.noreply.github.com>
…ed with correct URL

Co-authored-by: rilma <14822065+rilma@users.noreply.github.com>
Copilot AI changed the title [WIP] Update CI/CD pipeline upgrade and testing improvements test: mock network calls in test_retrieve Feb 21, 2026
Copilot AI requested a review from rilma February 21, 2026 21:03
@rilma rilma marked this pull request as ready for review February 21, 2026 21:04
@rilma rilma merged commit 0ad436a into features/upgrade-ci-cd Feb 21, 2026
@rilma rilma deleted the copilot/sub-pr-40 branch February 21, 2026 21:05
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