Skip to content

Commit db58809

Browse files
committed
Added new tests and imported correctly the new modules in init file
1 parent 8bec9f3 commit db58809

File tree

13 files changed

+1558
-17
lines changed

13 files changed

+1558
-17
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Bright Data Python SDK
22

3-
[![Tests](https://img.shields.io/badge/tests-237%20passing-brightgreen)](https://github.com/vzucher/brightdata-sdk-python)
3+
[![Tests](https://img.shields.io/badge/tests-365%20passing-brightgreen)](https://github.com/vzucher/brightdata-sdk-python)
44
[![Python](https://img.shields.io/badge/python-3.9%2B-blue)](https://www.python.org/)
55
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
66
[![Code Quality](https://img.shields.io/badge/quality-FAANG--level-gold)](https://github.com/vzucher/brightdata-sdk-python)
@@ -18,7 +18,7 @@ Modern async-first Python SDK for [Bright Data](https://brightdata.com) APIs wit
1818
- 🎯 **Dual namespace** - `scrape` (URL-based) + `search` (discovery)
1919
- 🔒 **100% type safety** - Full TypedDict definitions
2020
-**Zero code duplication** - DRY principles throughout
21-
-**237 comprehensive tests** - Unit, integration, and E2E
21+
-**365+ comprehensive tests** - Unit, integration, and E2E
2222
- 🎨 **Rich result objects** - Timing, cost tracking, method tracking
2323
- 🧩 **Extensible** - Registry pattern for custom platforms
2424
- 🔐 **.env file support** - Automatic loading via python-dotenv
@@ -599,7 +599,7 @@ from brightdata.utils.ssl_helpers import (
599599

600600
## 🧪 Testing
601601

602-
The SDK includes 237 comprehensive tests:
602+
The SDK includes 365+ comprehensive tests:
603603

604604
```bash
605605
# Run all tests
@@ -716,7 +716,7 @@ pytest tests/
716716

717717
- **Production Code:** ~7,500 lines
718718
- **Test Code:** ~3,500 lines
719-
- **Test Coverage:** 100% (237 tests passing)
719+
- **Test Coverage:** 100% (365+ tests passing)
720720
- **Supported Platforms:** Amazon, LinkedIn, ChatGPT, Facebook, Instagram, Generic Web
721721
- **Supported Search Engines:** Google, Bing, Yandex
722722
- **Type Safety:** 100% (TypedDict everywhere)

src/brightdata/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ async def get_account_info(self) -> AccountInfo:
336336

337337
try:
338338
async with self.engine:
339-
async with await self.engine.get_from_url(
339+
async with self.engine.get_from_url(
340340
f"{self.engine.BASE_URL}/zone/get_active_zones"
341341
) as zones_response:
342342
if zones_response.status == 200:

src/brightdata/scrapers/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@
1919
except ImportError:
2020
ChatGPTScraper = None
2121

22+
try:
23+
from .facebook.scraper import FacebookScraper
24+
except ImportError:
25+
FacebookScraper = None
26+
27+
try:
28+
from .instagram.scraper import InstagramScraper
29+
except ImportError:
30+
InstagramScraper = None
31+
32+
try:
33+
from .instagram.search import InstagramSearchScraper
34+
except ImportError:
35+
InstagramSearchScraper = None
36+
2237

2338
__all__ = [
2439
"BaseWebScraper",
@@ -29,4 +44,7 @@
2944
"AmazonScraper",
3045
"LinkedInScraper",
3146
"ChatGPTScraper",
47+
"FacebookScraper",
48+
"InstagramScraper",
49+
"InstagramSearchScraper",
3250
]

src/brightdata/utils/ssl_helpers.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ def is_ssl_certificate_error(error: Exception) -> bool:
3939
return True
4040

4141
# Check error message for SSL-related keywords
42-
error_str = str(error).lower()
42+
try:
43+
error_str = str(error)
44+
if error_str is None:
45+
error_str = ""
46+
error_str = error_str.lower()
47+
except (TypeError, AttributeError):
48+
# If __str__ returns None or raises an error, treat as non-SSL error
49+
return False
4350
ssl_keywords = [
4451
"certificate verify failed",
4552
"certificate verify",

tests/unit/test_amazon.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_products_method_signature(self):
5151
assert 'timeout' in sig.parameters
5252

5353
# Defaults
54-
assert sig.parameters['timeout'].default == 65
54+
assert sig.parameters['timeout'].default == 240
5555

5656
def test_reviews_method_signature(self):
5757
"""Test reviews method has correct signature."""
@@ -71,7 +71,7 @@ def test_reviews_method_signature(self):
7171
assert 'timeout' in sig.parameters
7272

7373
# Defaults
74-
assert sig.parameters['timeout'].default == 65
74+
assert sig.parameters['timeout'].default == 240
7575

7676
def test_sellers_method_signature(self):
7777
"""Test sellers method has correct signature."""
@@ -83,7 +83,7 @@ def test_sellers_method_signature(self):
8383
assert 'url' in sig.parameters
8484
assert 'sync' not in sig.parameters
8585
assert 'timeout' in sig.parameters
86-
assert sig.parameters['timeout'].default == 65
86+
assert sig.parameters['timeout'].default == 240
8787

8888

8989
class TestAmazonDatasetIDs:
@@ -149,7 +149,7 @@ def test_products_api_spec(self):
149149
assert 'url' in sig.parameters
150150
assert 'sync' not in sig.parameters
151151
assert 'timeout' in sig.parameters
152-
assert sig.parameters['timeout'].default == 65
152+
assert sig.parameters['timeout'].default == 240
153153

154154
def test_reviews_api_spec(self):
155155
"""Test reviews() matches CP API spec."""
@@ -295,10 +295,10 @@ def test_consistent_timeout_defaults(self):
295295

296296
import inspect
297297

298-
# All methods should default to 65s
298+
# All methods should default to 240s
299299
for method_name in ['products', 'reviews', 'sellers']:
300300
sig = inspect.signature(getattr(scraper, method_name))
301-
assert sig.parameters['timeout'].default == 65
301+
assert sig.parameters['timeout'].default == 240
302302

303303
def test_uses_standard_async_workflow(self):
304304
"""Test methods use standard async workflow (no sync parameter)."""

0 commit comments

Comments
 (0)