Skip to content

Test/57 add mock GitHub api server - #1021

Open
TanishaD111 wants to merge 6 commits into
ascherj:mainfrom
TanishaD111:test/57-add-mock-github-api-server
Open

Test/57 add mock GitHub api server#1021
TanishaD111 wants to merge 6 commits into
ascherj:mainfrom
TanishaD111:test/57-add-mock-github-api-server

Conversation

@TanishaD111

Copy link
Copy Markdown

Summary

This PR closes issue #57. The GitHubTool in agent/tools/github_tool.py calls the live GitHub REST API (https://api.github.com) to fetch repository metadata, so any integration test that exercises it needs real network access and is subject to GitHub's rate limits and auth. As a result, those tests are skipped in CI, there is currently no tests/integration/test_github_tool.py and no tests/fixtures/github_responses/ directory, leaving the tool's request handling and error paths (404, 403/rate limit) untested by automation. The fix is to stand up a lightweight local mock HTTP server (pytest-httpserver) that serves canned JSON fixtures for GitHub endpoints and to point the tool's base_url at it, so the GitHub tool tests can run deterministically and offline in CI without hitting the real API.

Issue

Closes #57

Changes

  • agent/tools/github_tool.py: added an optional base_url parameter to init (defaulting to a new DEFAULT_BASE_URL constant)
  • tests/fixtures/github_responses/: 4 canned responses: a fully-populated repo, one with explicit null description/language/homepage, and real GitHub 404 and 403 error bodies
  • tests/integration/test_github_tool.py: 10 tests / 14 cases covering 200 (full field mapping, asserted as one dict equality), 404, 403, 500, null-field coalescing, Authorization header forwarding, has_readme reflecting the HEAD /readme result, and missing/empty/None input across 5 parametrized shapes. Marked pytest.mark.integration

Testing

  • Unit tests pass (make test-unit)
  • Integration tests pass (make test-integration)
  • Linter passes (make lint)
  • Type checker passes (make typecheck)
  • New/updated tests cover the changes

Some of these errors are not from my files. The make test-integration passes all 14 tests for my issue.

Screenshots / Demo

n/a

Notes for Reviewers

n/a

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.

Add a mock GitHub API server for integration tests

1 participant