Skip to main content

django-object-manager

Simple, declarative, repeatable object management for Django tests

PyPI version Build Status Coverage Status

Examples:

# Model registration - usuallu in app/tests.py
# from .models import ...
from .models import User, Film, FilmCategory
from django_object_manager import ObjManagerMixin, ObjectManager


ObjectManager.register(
    User,
    {
        'bob': {
            'name': 'Bob',
            'email': 'bob@domain.com',
        },
        'alice': {
            'name': 'Alice',
            'email': 'alice@example.com',
        },
    })
ObjectManager.register(
    FilmCategory,
    {
        'drama': {
            'name': 'Drama',
        },
        'crime': {
            'name': 'Crime',
        },
        'serious': {
            'name': 'Adult films',
        },
        'anime': {
            'name': 'Anime',
            'parent': 'serious',
        },
    })
ObjectManager.register(
    Film,
    {
        'memento': {
            'name': 'Memento',
            'year': 2000,
            'uploaded_by': 'bob',
            'categories': ['crime', 'drama']
        },
})

# Further usage in tests:
object_manager = ObjectManager() # or self.object_manager if inherited from 
# Single object creation - 'bob' is previously registered idenitifier
bob = object_manager.get_user('bob')

# Object creation with attribute owerwriting
user3 = object_manager.get_user('bob', email='other@domain.com')

# Fully custom object creation
user = object_manager.get_user(name='Jack',
                               email='test@test.org')

# All predefined objects of given model - returns id:object dictionary
user = object_manager.get_users()


# Object with dependencies - dependencies are referenced by
# - their registered indentifiers
# - by passing already created object

memento = object_manager.get_film('memento') # Will create two categories and one user

Metadata

Release files for django-object-manager 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for django-object-manager 0.0.9
File Interpreter ABI Platform Actions
django_object_manager-0.0.9-py2.py3-none-any.whl Python 3, Python 2 none any Details for django_object_manager-0.0.9-py2.py3-none-any.whl

Release files / django_object_manager-0.0.9-py2.py3-none-any.whl

Download URL django_object_manager-0.0.9-py2.py3-none-any.whl
Size 9.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
5beccadc849b6e4731e687cd127a911a324e301af5436fde15759f211be3a61a
BLAKE2b-256 checksum
How to use checksums
fc77b8e0ac6f0f18cb8bf19d9a4984583feaa135c169557f1a90b6a1033e8057
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.2

Security for django-object-manager 0.0.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page