Django-admin-smoke
Django-Admin-Smoke is a Django app providing smoke tests for django-admin.
Installation
pip install django-admin-smoke
Usage
Full example located at testproject.testapp.tests
from admin_smoke.tests import AdminTests, AdminBaseTestCase
from testproject.testapp import admin, models
class ProjectAdminTestCase(AdminTests, AdminBaseTestCase):
model_admin = admin.ProjectAdmin # ModelAdmin to test
model = models.Project # Django model to test against
object_name = 'project' # self.project is an edited object in this testcase
excluded_fields = ['client'] # fields excluded from presence check
def setUp(self):
super().setUp()
# We need existing object to test editing and deleting
self.project = models.Project.objects.create(name='first')
# All inlines for tested model admin should be non-empty, so we fill
# all related models.
self.task = models.Task.objects.create(name='first',
project=self.project)
def transform_to_new(self, data: dict) -> dict:
# Creating a new object is tested with following algorithm:
# 1. Open "edit" page for existing object
# 2. Clear PK value in form data
# 3. Clear PK values for all related objects in admin inlines
# 4. Clear FK values pointing to existing object in admin inlines
# 5. POST resulting data to "add" page
# This algorithm need some help with unique fields and other constraints
# and restrictions, so there is a hook for making newly created object
# valid.
data = data.copy()
# Project.name is unique, making new value
data['name'] += 'new'
# Manually reset PK/FK values in admin inlines
self.reset_inline_data(
data, # form data
'task_set', # name of inline prefix - it's FK's related_name
'project' # name of edited object FK field (FK.name)
)
# Task.name is also unique, it should be changed properly
data['task_set-0-name'] += '_new'
return data
def prepare_deletion(self):
# To delete an object with FK's with models.PROTECT behavior we need
# a hook to delete it manually before POST delete confirmation.
self.task.delete()
Happy testing and non-smoky admins :)
Metadata
Release files for django-admin-smoke 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_admin_smoke-0.6.0.tar.gz | 8.3 kB | Without provenance | Details for django_admin_smoke-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_admin_smoke-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for django_admin_smoke-0.6.0-py3-none-any.whl |
Total release size: 15.8 kB
Release files / django_admin_smoke-0.6.0.tar.gz
| Download URL | django_admin_smoke-0.6.0.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
acc0e19bbfde0c0b0a4f70591a0f87afb15d02177523c1a15cdd321da057f107
|
|
BLAKE2b-256 checksum How to use checksums |
a1a1066c5d2b03a795be4a9c5806754d159298634fae416fc35626fae2964dba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / django_admin_smoke-0.6.0-py3-none-any.whl
| Download URL | django_admin_smoke-0.6.0-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3e1383f42a0855487e119b788cd4624b9f39fd2bca80c2f4d194aad389bc4b1a
|
|
BLAKE2b-256 checksum How to use checksums |
702f532795b50932ad144c08a655ca90973bc5966abc8074b1ad78ad98befddf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for django-admin-smoke 0.6.0
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.