Ticket #14896: 14896-test.diff
File 14896-test.diff, 2.2 KB (added by , 14 years ago) |
---|
-
tests/regressiontests/delete_regress/tests.py
4 4 from django.db import backend, connection, transaction, DEFAULT_DB_ALIAS 5 5 from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature 6 6 7 from models import Book, Award, AwardNote, Person, Child, Toy, PlayedWith, PlayedWithNote 7 from models import (Book, Award, AwardNote, Person, Child, Toy, PlayedWith, 8 PlayedWithNote, Contact, Email, Researcher) 8 9 9 10 10 11 # Can't run this test under SQLite, because you can't … … 62 63 transaction.commit() 63 64 self.assertEqual(1, Book.objects.count()) 64 65 65 class DeleteCascadeTests(T estCase):66 class DeleteCascadeTests(TransactionTestCase): 66 67 def test_generic_relation_cascade(self): 67 68 """ 68 69 Test that Django cascades deletes through generic-related … … 108 109 # first two asserts just sanity checks, this is the kicker: 109 110 self.assertEquals(PlayedWithNote.objects.count(), 0) 110 111 112 def test_inheritance(self): 113 r = Researcher.objects.create() 114 email = Email.objects.create( 115 label="office-email", email_address="carl@science.edu" 116 ) 117 r.contacts.add(email) 118 119 email.delete() 120 111 121 class LargeDeleteTests(TestCase): 112 122 def test_large_deletes(self): 113 123 "Regression for #13309 -- if the number of objects > chunk size, deletion still occurs" -
tests/regressiontests/delete_regress/models.py
35 35 class PlayedWithNote(models.Model): 36 36 played = models.ForeignKey(PlayedWith) 37 37 note = models.TextField() 38 39 class Contact(models.Model): 40 label = models.CharField(max_length=100) 41 42 class Email(Contact): 43 email_address = models.EmailField(max_length=100) 44 45 class Researcher(models.Model): 46 contacts = models.ManyToManyField(Contact, related_name="research_contacts")