Metadata-Version: 2.4
Name: iil-testkit
Version: 0.4.0
Summary: Shared test factory package for IIL Platform Django repos
License: MIT
Keywords: django,iil-platform,pytest,testing
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Django
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.11
Requires-Dist: pytest>=8.0
Provides-Extra: dev
Requires-Dist: beautifulsoup4>=4.12; extra == 'dev'
Requires-Dist: django>=4.2; extra == 'dev'
Requires-Dist: djangorestframework>=3.14; extra == 'dev'
Requires-Dist: factory-boy>=3.3; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest-django>=4.8; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Provides-Extra: django
Requires-Dist: django>=4.2; extra == 'django'
Requires-Dist: pytest-django>=4.8; extra == 'django'
Provides-Extra: drf
Requires-Dist: djangorestframework>=3.14; extra == 'drf'
Requires-Dist: pytest-django>=4.8; extra == 'drf'
Provides-Extra: smoke
Requires-Dist: beautifulsoup4>=4.12; extra == 'smoke'
Requires-Dist: django>=4.2; extra == 'smoke'
Requires-Dist: pytest-django>=4.8; extra == 'smoke'
Description-Content-Type: text/markdown

# iil-testkit

Shared test factory package for all IIL Platform Django repositories.

## Installation

```bash
pip install "iil-testkit[smoke]>=0.4.0,<1"
```

## Features

- **Fixtures**: `auth_client`, `staff_client`, `api_client`, `db_user`, `staff_user`, `admin_user`
- **Assertions**: `assert_htmx_response`, `assert_data_testids`, `assert_redirects_to_login`, `assert_no_n_plus_one`, `assert_form_error`
- **Smoke Testing**: `discover_smoke_urls()` — auto-discovers all parameterless Django views
- **ADR-048 Enforcement**: `assert_data_testids()` — verifies all `hx-*` elements have `data-testid`
- **Naming Convention**: Auto-enforces `test_should_*` prefix (ADR-057)

## Quick Start

```python
# tests/conftest.py
pytest_plugins = ["iil_testkit.fixtures"]

# tests/test_views_smoke.py
import pytest
from iil_testkit.smoke import discover_smoke_urls

_SMOKE_URLS: list[str] = discover_smoke_urls()

@pytest.mark.parametrize("url", _SMOKE_URLS)
@pytest.mark.django_db
def test_should_view_return_200(url: str, auth_client) -> None:
    response = auth_client.get(url)
    assert response.status_code in (200, 302)
```

## Scaffold Generator

```bash
python3 platform/scripts/gen_test_scaffold.py <repo-name>
```
