def test_empty_trash2(self): a1 = Apple.objects.create(color="red") Apple.objects.create(color="green") self.assertEqual(Apple.objects.count(), 2) self.assertEqual(Apple.trash.count(), 0) Apple.empty_trash() self.assertEqual(Apple.objects.count(), 2) self.assertEqual(Apple.trash.count(), 0) a1.delete() self.assertEqual(Apple.objects.count(), 2) self.assertEqual(Apple.trash.count(), 1) Apple.empty_trash() self.assertEqual(Apple.objects.count(), 1) self.assertEqual(Apple.trash.count(), 0) self.assertEqual(Apple.objects.all()[0].color, "green")
def test_empty_trash(self): Apple.empty_trash() self.assertEqual(Apple.objects.count(), 0) self.assertEqual(Apple.trash.count(), 0) a1 = Apple.objects.create(color="red") self.assertEqual(Apple.objects.count(), 1) self.assertEqual(Apple.trash.count(), 0) a1.empty_trash() self.assertEqual(Apple.objects.count(), 1) self.assertEqual(Apple.trash.count(), 0) a1.delete() self.assertEqual(Apple.objects.count(), 1) self.assertEqual(Apple.trash.count(), 1) a1.empty_trash() self.assertEqual(Apple.objects.count(), 0) self.assertEqual(Apple.trash.count(), 0)