Metadata-Version: 2.4
Name: iil-testkit
Version: 0.1.0
Summary: Shared Test Factory Package for all Platform Django repos
Project-URL: Homepage, https://github.com/achimdehnert/testkit
Project-URL: Repository, https://github.com/achimdehnert/testkit
Project-URL: Issues, https://github.com/achimdehnert/testkit/issues
Project-URL: Changelog, https://github.com/achimdehnert/testkit/blob/main/CHANGELOG.md
Author-email: Achim Dehnert <achim.dehnert@iil.gmbh>
License: MIT
Keywords: django,factory-boy,fixtures,pytest,testing
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Django
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Testing
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: factory-boy>=3.3.0
Provides-Extra: dev
Requires-Dist: django-stubs>=5.0; extra == 'dev'
Requires-Dist: django>=4.2; extra == 'dev'
Requires-Dist: hatch; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest-django>=4.8; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Provides-Extra: django
Requires-Dist: django>=4.2; extra == 'django'
Requires-Dist: pytest-django>=4.8; extra == 'django'
Description-Content-Type: text/markdown

# iil-testkit

**Shared Test Factory Package for all Platform Django repos** — [ADR-100](https://github.com/achimdehnert/platform/blob/main/docs/adr/ADR-100-iil-testkit-shared-test-factory-package.md)

## Installation

```bash
pip install iil-testkit
```

Or in `requirements-test.txt`:
```
iil-testkit>=0.1.0
```

## Usage

### Factories

```python
# tests/factories.py — import shared, extend repo-specific
from iil_testkit.factories import UserFactory
import factory

class BookProjectFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = "bfagent.BookProjects"
    user = factory.SubFactory(UserFactory)
    title = factory.Sequence(lambda n: f"Book {n}")
```

### Fixtures

```python
def test_should_view_dashboard(auth_client):
    response = auth_client.get("/dashboard/")
    assert response.status_code == 200
```

Available fixtures: `db_user`, `staff_user`, `admin_user`, `api_client`, `auth_client`, `staff_client`

### Assertion Helpers

```python
from iil_testkit.assertions import assert_redirects_to_login, assert_htmx_response

def test_should_redirect_unauthenticated(api_client):
    response = api_client.get("/protected/")
    assert_redirects_to_login(response)
```

### Naming Convention (ADR-057)

Auto-registered pytest plugin warns when test functions don't follow `test_should_*`:

```
PytestWarning: Naming convention: 'test_login' should start with 'test_should_'
```

Suppress with: `pytest --no-naming-check`

## Architecture

See [ADR-100](https://github.com/achimdehnert/platform/blob/main/docs/adr/ADR-100-iil-testkit-shared-test-factory-package.md).
