Testing
Applications built with the LongLink SDK can be tested using standard pytest and pytest-asyncio workflows. When a project is generated, these tools are already included as development dependencies in the pyproject.toml file.
To install the development dependencies, run:
bash
uv add .[dev]bash
pip install .[dev]Usage
You can execute all tests or target a specific test file using the following commands. Use sdk/tests for SDK test files and keep file paths aligned with the repository layout:
bash
pytest
pytest sdk/tests/cli/test_init.pyExample
Illustrative snippet: asynchronous testing with pytest
py
import pytest
@pytest.mark.asyncio
async def test_healthcheck(client):
response = await client.get('/health')
assert response.status_code == 200Illustrative snippet: testing with FastAPI TestClient
py
from app import app
from fastapi.testclient import TestClient
client = TestClient(app)
def test_healthcheck():
response = client.get("/health")
assert response.status_code == 200
assert response.json() == {"status": "ok"}