commit cc3381358bac66f15cc915dc926b535ee32c3240
Author: Honza Král <Honza.Kral@gmail.com>
Date: Tue Sep 2 00:09:05 2008 +0200
Added failing tests for generic relation delete()
diff --git a/tests/modeltests/generic_relations/models.py b/tests/modeltests/generic_relations/models.py
index 2f36e26..5a73ab4 100644
a
|
b
|
class Comparison(models.Model):
|
45 | 45 | def __unicode__(self): |
46 | 46 | return u"%s is %s than %s" % (self.first_obj, self.comparative, self.other_obj) |
47 | 47 | |
| 48 | class SomeModel(models.Model): |
| 49 | tag = models.ForeignKey(TaggedItem) |
| 50 | def __unicode__(self): |
| 51 | return unicode(self.tag) |
| 52 | |
48 | 53 | class Animal(models.Model): |
49 | 54 | common_name = models.CharField(max_length=150) |
50 | 55 | latin_name = models.CharField(max_length=150) |
… |
… |
__test__ = {'API_TESTS':"""
|
144 | 149 | >>> [(t.tag, t.content_type, t.object_id) for t in TaggedItem.objects.all()] |
145 | 150 | [(u'clearish', <ContentType: mineral>, 1), (u'fatty', <ContentType: vegetable>, 2), (u'fatty', <ContentType: animal>, 1), (u'hairy', <ContentType: animal>, 2), (u'salty', <ContentType: vegetable>, 2), (u'shiny', <ContentType: animal>, 1), (u'yellow', <ContentType: animal>, 2)] |
146 | 151 | |
| 152 | >>> ctype = ContentType.objects.get_for_model(lion) |
| 153 | >>> ti = TaggedItem.objects.get(content_type__id=ctype.pk, object_id=lion.pk, tag='hairy') |
| 154 | >>> sm = SomeModel( tag=ti ) |
| 155 | >>> sm.save() |
| 156 | >>> sm.tag |
| 157 | <TaggedItem: hairy> |
147 | 158 | >>> lion.delete() |
148 | 159 | >>> [(t.tag, t.content_type, t.object_id) for t in TaggedItem.objects.all()] |
149 | 160 | [(u'clearish', <ContentType: mineral>, 1), (u'fatty', <ContentType: vegetable>, 2), (u'fatty', <ContentType: animal>, 1), (u'salty', <ContentType: vegetable>, 2), (u'shiny', <ContentType: animal>, 1)] |
| 161 | >>> SomeModel.objects.all() |
| 162 | [] |
150 | 163 | |
151 | 164 | # If Generic Relation is not explicitly defined, any related objects |
152 | 165 | # remain after deletion of the source object. |