-
Notifications
You must be signed in to change notification settings - Fork 17
112 lines (94 loc) · 3.23 KB
/
Copy pathtest.yml
File metadata and controls
112 lines (94 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 2 * * *'
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['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
if: github.event_name == 'schedule'
strategy:
matrix:
python-version: ['3.8', '3.11']
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')
"