Skip to content

Commit 47f1ff5

Browse files
committed
fix: update tests to work with tool decorator and fix import sorting
- Reorganized imports in bright_data.py to follow PEP 8 standards - Revised tests to call bright_data function directly with parameters - Removed mock tool interface approach in favor of direct function testing - All tests now pass with the current tool decorator implementation
1 parent 0674024 commit 47f1ff5

File tree

2 files changed

+127
-168
lines changed

2 files changed

+127
-168
lines changed

src/strands_tools/bright_data.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,16 @@
7373
import logging
7474
import os
7575
import time
76-
from typing import Any, Dict, Optional
76+
from typing import Dict, Optional
7777
from urllib.parse import quote
78+
7879
import requests
7980
from rich.panel import Panel
8081
from rich.text import Text
81-
from strands_tools.utils import console_util
8282
from strands import tool
8383

84+
from strands_tools.utils import console_util
85+
8486
logger = logging.getLogger(__name__)
8587

8688
console = console_util.create()
@@ -141,7 +143,7 @@ def scrape_as_markdown(self, url: str, zone: Optional[str] = None) -> str:
141143
142144
Args:
143145
url (str): URL to scrape
144-
zone: Override default Web Unlocker zone name (optional).
146+
zone: Override default Web Unlocker zone name (optional).
145147
Must be a Web Unlocker zone - datacenter/residential zones will fail.
146148
Default: "web_unlocker"
147149
@@ -201,7 +203,7 @@ def search_engine(
201203
Args:
202204
query (str): Search query
203205
engine (str): Search engine - 'google', 'bing', or 'yandex'
204-
zone: Override default Web Unlocker zone name (optional).
206+
zone: Override default Web Unlocker zone name (optional).
205207
Must be a Web Unlocker zone - datacenter/residential zones will fail.
206208
Default: "web_unlocker"
207209
@@ -275,7 +277,6 @@ def search_engine(
275277
if return_json:
276278
params.append("brd_json=1")
277279

278-
279280
if params:
280281
search_url += "&" + "&".join(params)
281282

@@ -421,8 +422,8 @@ def bright_data(
421422
action: The action to perform (scrape_as_markdown, get_screenshot, search_engine, web_data_feed)
422423
url: URL to scrape or extract data from (for scrape_as_markdown, get_screenshot, web_data_feed)
423424
output_path: Path to save the screenshot (for get_screenshot)
424-
zone: Web Unlocker zone name (optional). If not provided, uses BRIGHTDATA_ZONE environment
425-
variable, or defaults to "web_unlocker1". Set BRIGHTDATA_ZONE in your .env file to
425+
zone: Web Unlocker zone name (optional). If not provided, uses BRIGHTDATA_ZONE environment
426+
variable, or defaults to "web_unlocker1". Set BRIGHTDATA_ZONE in your .env file to
426427
configure your specific Web Unlocker zone name (e.g., BRIGHTDATA_ZONE=web_unlocker_12345)
427428
query: Search query (for search_engine)
428429
engine: Search engine to use (google, bing, yandex, default: google)
@@ -504,4 +505,4 @@ def bright_data(
504505
border_style="red",
505506
)
506507
console.print(error_panel)
507-
raise
508+
raise

0 commit comments

Comments
 (0)