def test_book_autodelete(self): note1 = TextNote(text='text') note1.save() note2 = TextNote(text='text') note2.save() book = Book(title='title') book.save() book.note.add(*[note1, note2]) note1.delete() self.assertTrue(Book.objects.all()) note2.delete() self.assertFalse(Book.objects.all())
class CustomInclusionTagTest(TestCase): """Test for custom tag, that renders text note with given id""" def setUp(self): self.note = TextNote(text="Text note") self.note.save() self.id = str(self.note.id) self.TEMPLATE = Template("{% load custom_tag %} \ {% custom_tag "+self.id+" %}") def test_note_shows_up(self): rendered = self.TEMPLATE.render(Context({})) self.assertIn(self.note.text, rendered) def tearDown(self): self.note.delete() self.note = None