예제 #1
0
 def test_add_commit_handler(self):
     db = DataBase(store)
     old_report = db.report
     db.report = Mock()
     handler = Mock()
     db.add_commit_handler(handler)
     db.commit()
     self.assertEqual(db.report.call_count, 0)
     self.assertTrue(handler.called)
     self.assertEqual(handler.call_count, 1)
     handler = Mock()
     handler.side_effect = AE()
     db.add_commit_handler(handler)
     db.commit()
     self.assertEqual(db.report.call_count, 1)
     db.report = old_report
예제 #2
0
 def test_add_lazy_func(self):
     db = DataBase(store)
     old_report = db.report
     db.report = Mock()
     func = Mock()
     db.add_lazy_func(func)
     db.commit()
     self.assertEqual(db.report.call_count, 0)
     self.assertTrue(func.called)
     self.assertEqual(func.call_count, 1)
     func = Mock()
     func.side_effect = AE()
     db.add_lazy_func(func)
     db.commit()
     self.assertEqual(db.report.call_count, 1)
     db.report = old_report