Ticket #3215: 3215-testcase.patch

File 3215-testcase.patch, 1.3 KB (added by Russell Keith-Magee, 18 years ago)

Test case for deletion problem

  • tests/modeltests/generic_relations/models.py

     
    105105[<TaggedItem: shiny>]
    106106>>> TaggedItem.objects.filter(content_type__pk=ctype.id, object_id=quartz.id)
    107107[<TaggedItem: clearish>]
     108
     109# If you delete an object with an explicit Generic relation, the related
     110# objects are deleted when the source object is deleted.
     111>>> [(p.tag, p.content_type, p.object_id) for p in TaggedItem.objects.all()]
     112[('clearish', <ContentType: mineral>, 1), ('fatty', <ContentType: vegetable>, 2), ('hairy', <ContentType: animal>, 1), ('salty', <ContentType: vegetable>, 2), ('shiny', <ContentType: animal>, 2), ('yellow', <ContentType: animal>, 1)]
     113
     114>>> lion.delete()
     115>>> [(p.tag, p.content_type, p.object_id) for p in TaggedItem.objects.all()]
     116[('clearish', <ContentType: mineral>, 1), ('fatty', <ContentType: vegetable>, 2), ('salty', <ContentType: vegetable>, 2), ('shiny', <ContentType: animal>, 2)]
     117
     118# If Generic Relation is not explicitly defined, any tags remain after deletion.
     119>>> quartz.delete()
     120[('clearish', <ContentType: mineral>, 1), ('fatty', <ContentType: vegetable>, 2), ('salty', <ContentType: vegetable>, 2), ('shiny', <ContentType: animal>, 2)]
     121
    108122"""}
Back to Top