Skip to content

🧪 Add tests for SkillFetcher and fix missing timeouts#13

Open
frostmute wants to merge 1 commit intomainfrom
fix-fetcher-tests-2435492693691216413
Open

🧪 Add tests for SkillFetcher and fix missing timeouts#13
frostmute wants to merge 1 commit intomainfrom
fix-fetcher-tests-2435492693691216413

Conversation

@frostmute
Copy link
Copy Markdown
Owner

🎯 What: The testing gap addressed
Created tests for fetcher.py and specifically the SkillFetcher class. It had missing test coverage. Also discovered that requests.get requests were missing a timeout, which could cause indefinite hangs. Also fixed a small string matching bug for GitHub raw content paths (added githubusercontent.com).

📊 Coverage: What scenarios are now tested

  • Tested fetch_skill_from_github happy and unhappy paths.
  • Tested fetch_skill_from_clawhub_website happy (markdown block, and raw code block) and unhappy paths.
  • Tested discover_author_via_github happy and unhappy paths, including json deserialization and GitHub API returns empty logic.
  • Tested fetch_skill combining GitHub logic, author logic, and website scraping.

Result: The improvement in test coverage
Test coverage is now complete for fetcher.py. Also the module is more robust thanks to the proper timeout argument in network requests.


PR created automatically by Jules for task 2435492693691216413 started by @frostmute

Co-authored-by: frostmute <989225+frostmute@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces comprehensive unit tests for the SkillFetcher class and improves the robustness of network requests by adding a 10-second timeout to all requests.get calls. Additionally, the GitHub URL detection logic was updated to include githubusercontent.com. Review feedback suggests explicitly verifying the timeout argument in the new tests and removing an unused bs4 import.

Comment thread tests/test_fetcher.py
Comment on lines +15 to +17
content = fetcher.fetch_skill_from_github("author1", "skill1")
assert content == "test skill content"
mock_get.assert_called_once()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since a primary goal of this pull request is to ensure network requests have timeouts, the tests should explicitly verify that the timeout argument is passed to requests.get. This makes the tests more robust and ensures the fix is actually working as intended. Using assert_called_once_with allows checking both the URL and the timeout value.

Suggested change
content = fetcher.fetch_skill_from_github("author1", "skill1")
assert content == "test skill content"
mock_get.assert_called_once()
content = fetcher.fetch_skill_from_github("author1", "skill1")
assert content == "test skill content"
mock_get.assert_called_once_with(
"https://raw.githubusercontent.com/openclaw/skills/main/skills/author1/skill1/SKILL.md",
timeout=10
)

Comment thread tests/test_fetcher.py
from unittest.mock import patch, MagicMock
from claw2manus.fetcher import SkillFetcher
import requests
import bs4
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The bs4 module is imported but not used in this test file. The BeautifulSoup class is patched within the claw2manus.fetcher module using a string reference, so this top-level import is unnecessary and can be removed to keep the code clean.

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.

1 participant