mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-03-16 22:20:26 +00:00
Add failing test for diffing polymorphic model instances.
This commit is contained in:
parent
074e6aa145
commit
632b1c6b04
2 changed files with 23 additions and 0 deletions
|
|
@ -487,6 +487,7 @@ auditlog.register(AltPrimaryKeyModel)
|
|||
auditlog.register(UUIDPrimaryKeyModel)
|
||||
auditlog.register(ModelPrimaryKeyModel)
|
||||
auditlog.register(ProxyModel)
|
||||
auditlog.register(RelatedModelParent)
|
||||
auditlog.register(RelatedModel)
|
||||
auditlog.register(ManyRelatedModel)
|
||||
auditlog.register(ManyRelatedModel.recursive.through)
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ from test_app.models import (
|
|||
NullableJSONModel,
|
||||
ProxyModel,
|
||||
RelatedModel,
|
||||
RelatedModelParent,
|
||||
ReusableThroughRelatedModel,
|
||||
SecretM2MModel,
|
||||
SecretRelatedModel,
|
||||
|
|
@ -2131,6 +2132,27 @@ class ModelInstanceDiffTest(TestCase):
|
|||
model_instance_diff(simple2, simple1)
|
||||
model_instance_diff(simple1, simple2)
|
||||
|
||||
def test_diff_polymorphic_models(self):
|
||||
"""No error is raised when comparing parent/child for polymorphic models."""
|
||||
|
||||
# This tests that when a polymorphic model is compared to its parent,
|
||||
# no FieldDoesNotExist errors are raised because those fields don't exist
|
||||
# on the parent model.
|
||||
|
||||
# relation target
|
||||
simple = SimpleModel()
|
||||
simple.save()
|
||||
|
||||
# the parent model
|
||||
related_parent = RelatedModelParent()
|
||||
related_parent.save()
|
||||
|
||||
# the child model, with some fields that don't exist on the parent
|
||||
related = RelatedModel(related=simple, one_to_one=simple)
|
||||
related.save()
|
||||
|
||||
model_instance_diff(related, related_parent)
|
||||
|
||||
def test_object_repr_related_deleted(self):
|
||||
"""No error is raised when __str__() loads a related object that has been deleted."""
|
||||
simple = SimpleModel()
|
||||
|
|
|
|||
Loading…
Reference in a new issue