def setUp(self, mock_get_session, mock_member_repo, mock_health_repo, mock_pool_repo, mock_l7r_repo, mock_l7p_repo, mock_list_repo, mock_lb_repo): super(TestDriverUpdater, self).setUp() self.mock_session = "FAKE_DB_SESSION" mock_get_session.return_value = self.mock_session member_mock = mock.MagicMock() mock_member_repo.return_value = member_mock self.mock_member_repo = member_mock health_mock = mock.MagicMock() mock_health_repo.return_value = health_mock self.mock_health_repo = health_mock pool_mock = mock.MagicMock() mock_pool_repo.return_value = pool_mock self.mock_pool_repo = pool_mock l7r_mock = mock.MagicMock() mock_l7r_repo.return_value = l7r_mock self.mock_l7r_repo = l7r_mock l7p_mock = mock.MagicMock() mock_l7p_repo.return_value = l7p_mock self.mock_l7p_repo = l7p_mock list_mock = mock.MagicMock() mock_list_repo.return_value = list_mock self.mock_list_repo = list_mock lb_mock = mock.MagicMock() mock_lb_repo.return_value = lb_mock self.mock_lb_repo = lb_mock self.driver_updater = driver_updater.DriverUpdater() self.ref_ok_response = { lib_consts.STATUS_CODE: lib_consts.DRVR_STATUS_CODE_OK }
def handle(self): # Get the update data stats = _recv(self.request) # Process the update updater = driver_updater.DriverUpdater() response = updater.update_listener_statistics(stats) # Send the response json_data = jsonutils.dump_as_bytes(response) len_str = '{}\n'.format(len(json_data)).encode('utf-8') self.request.send(len_str) self.request.sendall(json_data)
def setUp(self, mock_get_session, mock_member_repo, mock_health_repo, mock_pool_repo, mock_l7r_repo, mock_l7p_repo, mock_list_repo, mock_lb_repo): super().setUp() self.mock_session = "FAKE_DB_SESSION" mock_get_session.return_value = self.mock_session member_mock = mock.MagicMock() mock_member_repo.return_value = member_mock self.mock_member_repo = member_mock health_mock = mock.MagicMock() mock_health_repo.return_value = health_mock self.mock_health_repo = health_mock pool_mock = mock.MagicMock() mock_pool_repo.return_value = pool_mock self.mock_pool_repo = pool_mock l7r_mock = mock.MagicMock() mock_l7r_repo.return_value = l7r_mock self.mock_l7r_repo = l7r_mock l7p_mock = mock.MagicMock() mock_l7p_repo.return_value = l7p_mock self.mock_l7p_repo = l7p_mock list_mock = mock.MagicMock() mock_list_repo.return_value = list_mock self.mock_list_repo = list_mock lb_mock = mock.MagicMock() mock_lb_repo.return_value = lb_mock self.mock_lb_repo = lb_mock self.driver_updater = driver_updater.DriverUpdater() self.ref_ok_response = {lib_consts.STATUS_CODE: lib_consts.DRVR_STATUS_CODE_OK} mock_lb = mock.MagicMock() self.lb_id = uuidutils.generate_uuid() self.lb_project_id = uuidutils.generate_uuid() mock_lb.id = self.lb_id mock_lb.project_id = self.lb_project_id mock_lb.provisioning_status = lib_consts.ACTIVE self.lb_data_model = 'FakeLBDataModel' self.mock_lb_repo.model_class.__data_model__ = self.lb_data_model self.mock_lb_repo.get.return_value = mock_lb