conftest.py•1.17 kB
"""Pytest configuration and fixtures."""
from unittest.mock import AsyncMock, Mock
import httpx
import pytest
@pytest.fixture
def mock_httpx_response():
"""Create a mock httpx response."""
response = Mock(spec=httpx.Response)
response.status_code = 200
response.headers = {"content-type": "application/json"}
response.url = httpx.URL("https://biocache-ws.ala.org.au/ws/occurrences")
response.json.return_value = {"totalRecords": 100, "records": []}
response.text = '{"totalRecords": 100, "records": []}'
return response
@pytest.fixture
def mock_httpx_client(mock_httpx_response):
"""Create a mock httpx async client."""
client = AsyncMock(spec=httpx.AsyncClient)
client.request.return_value = mock_httpx_response
return client
@pytest.fixture
def sample_api_response():
"""Sample ALA API response data."""
return {
"totalRecords": 10,
"records": [
{
"uuid": "test-uuid-1",
"scientificName": "Eucalyptus camaldulensis",
"decimalLatitude": -37.8136,
"decimalLongitude": 144.9631,
}
],
}