Browse Source

test if game objectives are deleted recursively

testing
Burathar 4 years ago
parent
commit
ef29816a96
  1. 16
      app/models/tests/test_objective.py

16
app/models/tests/test_objective.py

@ -45,5 +45,21 @@ class ObjectiveCase(unittest.TestCase):
self.assertTrue(o1.owned_by(u1)) self.assertTrue(o1.owned_by(u1))
self.assertFalse(o2.owned_by(u1)) self.assertFalse(o2.owned_by(u1))
def test_delete_objectives_recursively(self):
g1 = Game(name='TestGame')
o1 = Objective(name='o1')
o1.set_hash()
g1.objectives.append(o1)
db.session.add(g1)
db.session.commit()
self.assertNotEqual(Objective.query.filter_by(name='o1').first(), None)
db.session.delete(g1)
db.session.commit()
self.assertEqual(Objective.query.filter_by(name='o1').first(), None)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main(verbosity=2) unittest.main(verbosity=2)

Loading…
Cancel
Save