def test_last_successful_upgrade(self):
        database = factory.DatabaseFactory()
        self.assertIsNone(database.last_successful_upgrade)

        upgrade = maintenance_factory.DatabaseUpgradeFactory()
        upgrade.database = database

        upgrade.save()
        self.assertIsNone(database.last_successful_upgrade)

        upgrade.set_success()
        self.assertEqual(database.last_successful_upgrade, upgrade)
 def test_last_successful_upgrade_with_error(self):
     database = factory.DatabaseFactory()
     upgrade = maintenance_factory.DatabaseUpgradeFactory()
     upgrade.database = database
     upgrade.set_error()
     self.assertIsNone(database.last_successful_upgrade)