test: add unit and integration test suite for the new SDK

- 268 unit tests covering all sync and async client methods
- 196 integration tests against a real sandbox API
- Mock-based tests using respx for sync and async HTTP mocking
- Paging, error handling, and edge case coverage (400/401/403/404/500/418)
- Integration test utilities and test data files
- .env.example with sandbox environment variables
This commit is contained in:
Stevan Freeborn
2026-06-26 17:43:08 -05:00
parent b976959c30
commit 6774f42c2f
18 changed files with 5716 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
import os
import pytest
from onspring_api_sdk import OnspringClient
from onspring_api_sdk.models import Record, StringFieldValue
def add_record(base_url: str, api_key: str) -> int:
client = OnspringClient(base_url, api_key)
survey_id = os.environ.get("TEST_SURVEY_ID")
text_field = os.environ.get("TEST_TEXT_FIELD")
if survey_id is None:
pytest.fail("TEST_SURVEY_ID is not defined")
if text_field is None:
pytest.fail("TEST_TEXT_FIELD is not defined")
app_id = int(survey_id)
field_id = int(text_field)
record = Record(
app_id=app_id,
fields=[StringFieldValue(field_id=field_id, value="test")],
)
response = client.add_or_update_record(record)
if response.data is None or response.data.id is None:
pytest.fail("Record ID is not defined")
return response.data.id