def test_listener_start(self, mock_driver, mock_generate_uuid, mock_log, mock_get_session, mock_listener_repo_get, mock_listener_repo_update, mock_amphora_repo_update): listener_start_obj = amphora_driver_tasks.ListenerStart() listener_start_obj.execute(_load_balancer_mock, _listener_mock) mock_driver.start.assert_called_once_with(_listener_mock, _vip_mock) # Test the revert amp = listener_start_obj.revert(_listener_mock) repo.ListenerRepository.update.assert_called_once_with( _session_mock, id=LISTENER_ID, provisioning_status=constants.ERROR) self.assertIsNone(amp) # Test the revert with exception repo.ListenerRepository.update.reset_mock() mock_listener_repo_update.side_effect = Exception('fail') amp = listener_start_obj.revert(_listener_mock) repo.ListenerRepository.update.assert_called_once_with( _session_mock, id=LISTENER_ID, provisioning_status=constants.ERROR) self.assertIsNone(amp)
def test_listener_start(self, mock_driver, mock_generate_uuid, mock_log, mock_get_session, mock_listener_repo_update, mock_amphora_repo_update): listener_start_obj = amphora_driver_tasks.ListenerStart() listener_start_obj.execute(_listener_mock, _vip_mock) mock_driver.start.assert_called_once_with(_listener_mock, _vip_mock) # Test the revert amp = listener_start_obj.revert(_listener_mock) repo.ListenerRepository.update.assert_called_once_with( 'TEST', id=LISTENER_ID, provisioning_status=constants.ERROR) self.assertIsNone(amp)