def test_add_supervisor_second_exception(self, mock_db): mock_db().commit_data.side_effect = ['', '', sqlite3.IntegrityError] admin = Admin() admin.add_supervisor(1, 1) self.assertEqual(3, mock_db().commit_data.call_count)
def test_add_supervisor_third_exception(self, mock_db): mock_db().change_accident_to_wip.side_effect = Exception admin = Admin() admin.add_supervisor(1, 1) mock_db().rollback_data.assert_called_once()
def test_add_supervisor(self, mock_db): admin = Admin() admin.add_supervisor(1, 1) self.assertEqual(3, mock_db().commit_data.call_count)