Skip to content

Update scrape_chatgpt_example.py #29

Update scrape_chatgpt_example.py

Update scrape_chatgpt_example.py #29

Workflow file for this run

name: Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov
- name: Test package import
run: |
python -c "import brightdata; print('✅ Import successful')"
- name: Run tests
run: |
python -m pytest tests/ -v --cov=brightdata --cov-report=xml
- name: Upload coverage to Codecov
if: matrix.python-version == '3.8'
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
test-pypi-package:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.11'] # Test on fewer versions for PyPI to save CI time
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install PyPI package
run: |
python -m pip install --upgrade pip
pip install brightdata-sdk
pip install pytest
- name: Test PyPI package import
run: |
python -c "import brightdata; print('✅ PyPI package import successful')"
python -c "from brightdata import bdclient; print('✅ bdclient import successful')"
- name: Test PyPI package basic functionality
run: |
python -c "
from brightdata import bdclient, __version__
print(f'✅ PyPI package version: {__version__}')
try:
client = bdclient(api_token='test_token_too_short')
except Exception as e:
print(f'✅ Expected validation error: {e}')
if 'API token appears to be invalid' in str(e):
print('✅ PyPI package validation working correctly')
else:
raise Exception('Unexpected error message')
"
- name: Run basic tests against PyPI package
run: |
# Copy test files to temp directory to avoid importing local code
mkdir /tmp/pypi_tests
cp tests/test_client.py /tmp/pypi_tests/
cd /tmp/pypi_tests
# Run a subset of tests that don't require mocking internal methods
python -c "
import sys
sys.path.insert(0, '.')
from test_client import TestBdClient
import pytest
# Run only basic validation tests
test_instance = TestBdClient()
print('✅ Running PyPI package validation tests...')
try:
# Test that requires no token should fail
pytest.raises(Exception, lambda: __import__('brightdata').bdclient())
print('✅ No token validation works')
except:
pass
print('✅ PyPI package basic tests completed')
"