def test_update_deleted_object(self):
     person = PersonFactory(deleted=True)
     # undelete the object
     person.deleted = False
     person.save()
     undeleted_person = Person.objects.get(id=person.id)
     self.assertFalse(undeleted_person.deleted)
 def test_update_deleted_object(self):
     person = PersonFactory(deleted=True)
     # undelete the object
     person.deleted = False
     person.save()
     undeleted_person = Person.objects.get(id=person.id)
     self.assertFalse(undeleted_person.deleted)
class AbstractTimestampModelTest(TestCase):
    def setUp(self):
        self.before = timezone.now()
        self.obj = PersonFactory()

    def test_creation_date(self):
        after = timezone.now()
        self.assertGreater(self.obj.creation_date, self.before)
        self.assertLess(self.obj.creation_date, after)

    def test_modification_date(self):
        modification_date = self.obj.modification_date
        self.assertTrue(modification_date)
        self.obj.save()
        self.assertGreater(self.obj.modification_date, modification_date)
class AbstractTimestampModelTest(TestCase):
    def setUp(self):
        self.before = timezone.now()
        self.obj = PersonFactory()

    def test_creation_date(self):
        after = timezone.now()
        self.assertGreater(self.obj.creation_date, self.before)
        self.assertLess(self.obj.creation_date, after)

    def test_modification_date(self):
        modification_date = self.obj.modification_date
        self.assertTrue(modification_date)
        self.obj.save()
        self.assertGreater(self.obj.modification_date, modification_date)
 def test_dont_get_deleted_objects_by_default(self):
     person = PersonFactory()
     self.assertIn(person, Person.objects.all())
     person.deleted = True
     person.save()
     self.assertNotIn(person, Person.objects.all())
 def test_dont_get_deleted_objects_by_default(self):
     person = PersonFactory()
     self.assertIn(person, Person.objects.all())
     person.deleted = True
     person.save()
     self.assertNotIn(person, Person.objects.all())