Skip to content

Latest commit

 

History

History
126 lines (88 loc) · 3.49 KB

testing_notes.md

File metadata and controls

126 lines (88 loc) · 3.49 KB

Testing Documentation/Notes

Coverage Status

Hello, friend! You have found the list of test cases that this package can benefit from.

You seem concerned about the stability and reliability of this package. You're probably wondering if you should include it in your production codebase. Well, although I have tried very hard to get 100% code coverage, there are so many permutations of ModelAdmins in the wild. And I'm only one person.

So if you want to include this package in your production codebase, be aware that AdminConfirmMixin works best with simple unmodified ModelAdmins.

Probable Issues

These are some areas which might/probably have issues that are not currently tested. Use at your own risk!

  • Saving file/image changes on inlines when confirming change on parent model

Save Options

  • Save
  • Continue
  • Save As New
  • Add another

Field types

  • CharField
  • PositiveIntegerField
  • DecimalField
  • TextField
  • ImageField
  • FileField
  • ManyToManyField
  • OneToOneField
  • ForeignKey
  • DateField
  • DateTimeField
  • Custom Readonly fields

Options

  • .exclude
  • .fields
  • .readonly_fields
  • Actions

Options to test

  • ModelAdmin.fieldsets
  • ModelAdmin.form
  • ModelAdmin.raw_id_fields
  • ModelAdmin.radio_fields
  • ModelAdmin.autocomplete_fields
  • ModelAdmin.prepopulated_fields

ModelAdmin form template overrides?

https://docs.djangoproject.com/en/3.1/ref/contrib/admin/#custom-template-options (Maybe??? IDK this is esoteric)

Function overrides to test

  • .save_model()
  • .get_readonly_fields()
  • .get_fields()
  • .get_excludes()
  • .get_form()
  • .get_autocomplete_fields()
  • .get_prepopulated_fields()
  • .get_fieldsets()
  • ModelAdmin.formfield_for_manytomany()
  • ModelAdmin.formfield_for_foreignkey()
  • ModelAdmin.formfield_for_choice_field()
  • ModelAdmin.get_changeform_initial_data()

Inline instance support??

Confirmation on inline changes is not a current feature of this project.

Confirmation on add/change of ModelAdmin that includes inlines needs to be tested. Use AdminConfirmMixin with ModelAdmin containing inlines at your own risk.

  • .inlines
  • .get_inline_instances()
  • .get_inlines() (New in Django 3.0)
  • .get_formsets_with_inlines() ???

Options for inlines

  • classes of inlines: Tabular, Stacked, etc
  • extra
  • action on the inline: add or change
  • clicking add another on the inline

IDK if we want to support these

  • .get_changelist_form()

  • ModelAdmin.list_editable

  • ModelAdmin.changelist_view()

  • ModelAdmin.add_view(request, form_url='', extra_context=None)

  • ModelAdmin.change_view(request, object_id, form_url='', extra_context=None)

More tests for these?

Note: Currently the code always calls super()._changeform_view(), which would ensure permissions correct as well

  • ModelAdmin.has_add_permission
  • ModelAdmin.has_change_permission

Tests for confirming models/forms with validations

  • ModelForm.clean_field
  • ModelForm.clean
  • Model.clean
  • validator on the model field

There are other possible combos of theses

Tests where save functions are overridden

  • ModelForm.save
  • ModelAdmin.save_model

Tests for storage backends for ImageField and FileField

  • Local storage
  • S3