Skip to main content

Shared Test Factory Package for all Platform Django repos

Project description

iil-testkit

Shared Test Factory Package for all Platform Django reposADR-100

Installation

pip install iil-testkit

Or in requirements-test.txt:

iil-testkit>=0.1.0

Usage

Factories

# 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

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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iil_testkit-0.1.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iil_testkit-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file iil_testkit-0.1.0.tar.gz.

File metadata

  • Download URL: iil_testkit-0.1.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for iil_testkit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8b55f43eb68ca5d67528100b2f1bf7d43ef4432cd630660915b67aec64d1b2fd
MD5 e016cd038b7fa7d76733a79315d7de09
BLAKE2b-256 96ca3a46d0eb9ce8c73b280cbeacc19e4d4e0e0bd6d6b8a1c2a2f0e47f350beb

See more details on using hashes here.

Provenance

The following attestation bundles were made for iil_testkit-0.1.0.tar.gz:

Publisher: publish.yml on achimdehnert/testkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file iil_testkit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: iil_testkit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for iil_testkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e83c4d8526e053a31cef83947134a5d06d3f483cd6b2b3d9406afd308403e0f1
MD5 4d5f964d803ef7e322d609a2af3dfa7e
BLAKE2b-256 023b23535531a8704cee90e864386cb5a64a99aa31f2ead040cf85bea332770b

See more details on using hashes here.

Provenance

The following attestation bundles were made for iil_testkit-0.1.0-py3-none-any.whl:

Publisher: publish.yml on achimdehnert/testkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page