-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (132 loc) · 4.74 KB
/
sdk-validation.yml
File metadata and controls
157 lines (132 loc) · 4.74 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: SDK Validation
on:
workflow_call:
secrets:
IPTU_TEST_API_KEY:
required: true
workflow_dispatch:
push:
branches: [main]
schedule:
- cron: '0 6 * * *' # Daily at 6 AM UTC
env:
API_BASE_URL: https://api.iptuapi.com.br
jobs:
clean-environment-test:
name: Clean Environment Test
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Create clean virtual environment
run: |
python -m venv /tmp/sdk-clean-test
source /tmp/sdk-clean-test/bin/activate
- name: Install SDK from PyPI registry
run: |
source /tmp/sdk-clean-test/bin/activate
pip install iptuapi
- name: Test import
run: |
source /tmp/sdk-clean-test/bin/activate
cat > /tmp/test_import.py << 'EOF'
from iptuapi import IPTUClient
if not IPTUClient:
raise ImportError("IPTUClient not found")
print("Import successful")
EOF
python /tmp/test_import.py
- name: Verify package structure
run: |
source /tmp/sdk-clean-test/bin/activate
cat > /tmp/verify_structure.py << 'EOF'
import iptuapi
import inspect
from iptuapi import IPTUClient
print("IPTUClient class found")
methods = ["consulta_endereco", "iptu_tools_cidades"]
for method in methods:
if hasattr(IPTUClient, method):
print(f"Method {method} found")
else:
print(f"Warning: Method {method} not found")
EOF
python /tmp/verify_structure.py
smoke-test-real-api:
name: Smoke Test Real API
runs-on: ubuntu-latest
needs: clean-environment-test
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Create clean virtual environment
run: python -m venv /tmp/sdk-smoke-test
- name: Install SDK from PyPI registry
run: |
source /tmp/sdk-smoke-test/bin/activate
pip install iptuapi
- name: Test iptuToolsCidades endpoint
env:
IPTU_TEST_API_KEY: ${{ secrets.IPTU_TEST_API_KEY }}
run: |
source /tmp/sdk-smoke-test/bin/activate
cat > /tmp/test_cidades.py << 'EOF'
import os
from iptuapi import IPTUClient
api_key = os.environ.get("IPTU_TEST_API_KEY")
if not api_key:
raise ValueError("IPTU_TEST_API_KEY not set")
print("Testing iptuToolsCidades...")
client = IPTUClient(api_key=api_key)
result = client.iptu_tools_cidades()
if not isinstance(result.get("cidades"), list):
raise ValueError("Expected cidades to be a list")
total = result.get("total", 0)
if total < 9:
raise ValueError(f"Expected at least 9 cidades, got {total}")
print("iptuToolsCidades test passed!")
print(f"Total cidades: {total}")
EOF
python /tmp/test_cidades.py
- name: Test authenticated endpoint (consultaEndereco)
env:
IPTU_TEST_API_KEY: ${{ secrets.IPTU_TEST_API_KEY }}
run: |
source /tmp/sdk-smoke-test/bin/activate
cat > /tmp/test_auth.py << 'EOF'
import os
from iptuapi import IPTUClient
api_key = os.environ.get("IPTU_TEST_API_KEY")
if not api_key:
raise ValueError("IPTU_TEST_API_KEY not set")
print("Testing consultaEndereco (authenticated endpoint)...")
client = IPTUClient(api_key=api_key)
result = client.consulta_endereco(
logradouro="Avenida Paulista",
numero="1000",
cidade="sp"
)
if not result.get("success"):
raise ValueError("Expected success to be true")
dados_iptu = result.get("dados_iptu", {})
sql = dados_iptu.get("sql")
if not sql or not isinstance(sql, str):
raise ValueError("Expected dados_iptu.sql to be a non-empty string")
print("Authenticated endpoint test passed!")
print(f"SQL field present: {sql[:50]}...")
EOF
python /tmp/test_auth.py
- name: Validation complete
run: |
echo "All SDK validation tests passed!"
echo "- Clean environment install: OK"
echo "- Python import: OK"
echo "- Public API (iptuToolsCidades): OK"
echo "- Authenticated API (consultaEndereco): OK"