class TestHomeHandler(unittest.TestCase): """ test case for HomeHandler """ def setUp(self): self.handlers = mock.MagicMock() self.settings = mock.MagicMock() self.database = {"database": DATABASE_NAME} self.home_handler = HomeHandler(self.handlers, self.settings, **self.database) def test_get(self): """ test case for method get """ self.home_handler.cursor = mock.MagicMock() self.home_handler.render = mock.MagicMock() self.home_handler.employee_obj = mock.MagicMock() self.home_handler.db = mock.MagicMock() self.home_handler.get() self.home_handler.cursor.execute.assert_called_once_with('SELECT * FROM employee') self.home_handler.db.commit.assert_called_with() self.home_handler.db.close.assert_called_with() self.home_handler.cursor.fetchall.assert_called_with()
def setUp(self): self.handlers = mock.MagicMock() self.settings = mock.MagicMock() self.database = {"database": DATABASE_NAME} self.home_handler = HomeHandler(self.handlers, self.settings, **self.database)