From ef29816a967254e501c3a13e8503531ddc607d5f Mon Sep 17 00:00:00 2001 From: Burathar Date: Wed, 19 Aug 2020 14:33:38 +0200 Subject: [PATCH] test if game objectives are deleted recursively --- app/models/tests/test_objective.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/models/tests/test_objective.py b/app/models/tests/test_objective.py index e04f7ee..8167c62 100644 --- a/app/models/tests/test_objective.py +++ b/app/models/tests/test_objective.py @@ -45,5 +45,21 @@ class ObjectiveCase(unittest.TestCase): self.assertTrue(o1.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__': unittest.main(verbosity=2)