Skip to content

Conversation

@goblin0xcrypto
Copy link
Contributor

@goblin0xcrypto goblin0xcrypto commented Jan 28, 2026

Add Comprehensive Test Coverage for DeepSeekLLM Plugin

Summary

This PR adds comprehensive unit tests for the DeepSeekLLM plugin to improve code quality and maintainability.


Test Coverage

⚙️ Configuration & Initialization Tests

  • Test successful initialization with provided configuration
  • Test fallback to default model (deepseek-chat) when model is not specified
  • Test validation that raises ValueError when API key is missing
  • Test configuration with custom base URL and model

🧠 Core Functionality Tests

  • Test successful API request without tool calls (returns None)
  • Test successful API request with single tool call
  • Test successful API request with multiple tool calls
  • Test handling of empty response choices (returns None)
  • Test handling of invalid JSON responses (returns empty CortexOutputModel)

🛠️ Error Handling Tests

  • Test graceful error handling for API exceptions (returns None)

📊 Performance & Monitoring Tests

  • Test I/O provider timing metrics collection (llm_start_time and llm_end_time)
  • Test timeout configuration is properly passed to API

Files Changed

  • tests/llm/plugins/test_deepseek_llm.py (new)

@goblin0xcrypto goblin0xcrypto requested a review from a team as a code owner January 28, 2026 17:23
@github-actions github-actions bot added python Python code tests Test files labels Jan 28, 2026
@codecov
Copy link

codecov bot commented Feb 4, 2026

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
2197 2 2195 0
View the top 2 failed test(s) by shortest run time
tests/llm/plugins/test_deepseek_llm.py::test_ask_with_messages
Stack Traces | 0.03s run time
llm = <llm.plugins.deepseek_llm.DeepSeekLLM object at 0x7f544ef239a0>
mock_response = <MagicMock id='140000078474704'>

    @pytest.mark.asyncio
    async def test_ask_with_messages(llm, mock_response):
        """Test API call with message history"""
        messages = [
            {"role": "user", "content": "previous message"},
            {"role": "assistant", "content": "previous response"}
        ]
    
        with pytest.MonkeyPatch.context() as m:
            mock_create = AsyncMock(return_value=mock_response)
            m.setattr(llm._client.chat.completions, "create", mock_create)
    
>           await llm.ask("test prompt", messages=messages)

.../llm/plugins/test_deepseek_llm.py:217: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/providers/avatar_llm_state_provider.py:169: in wrapper
    raise e
src/providers/avatar_llm_state_provider.py:160: in wrapper
    result = await f(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <llm.plugins.deepseek_llm.DeepSeekLLM object at 0x7f544ef239a0>
prompt = 'test prompt', args = ()
kwargs = {'messages': [{'content': 'previous message', 'role': 'user'}, {'content': 'previous response', 'role': 'assistant'}]}

    @functools.wraps(func)
    async def wrapper(self: Any, prompt: str, *args: Any, **kwargs: Any) -> R:
        if getattr(self, "_skip_state_management", False):
            return await func(self, prompt, *args, **kwargs)
    
        if self._config.history_length == 0:
>           response = await func(self, prompt, [], *args, **kwargs)
E           TypeError: DeepSeekLLM.ask() got multiple values for argument 'messages'

src/providers/llm_history_manager.py:311: TypeError
tests/llm/plugins/test_deepseek_llm.py::test_messages_missing_role_or_content
Stack Traces | 0.031s run time
llm = <llm.plugins.deepseek_llm.DeepSeekLLM object at 0x7f544eb43820>
mock_response = <MagicMock id='140000077806560'>

    @pytest.mark.asyncio
    async def test_messages_missing_role_or_content(llm, mock_response):
        """Test handling of malformed messages"""
        messages = [
            {"role": "user"},  # missing content
            {"content": "test"}  # missing role
        ]
    
        with pytest.MonkeyPatch.context() as m:
            mock_create = AsyncMock(return_value=mock_response)
            m.setattr(llm._client.chat.completions, "create", mock_create)
    
>           result = await llm.ask("test prompt", messages=messages)

.../llm/plugins/test_deepseek_llm.py:287: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/providers/avatar_llm_state_provider.py:169: in wrapper
    raise e
src/providers/avatar_llm_state_provider.py:160: in wrapper
    result = await f(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <llm.plugins.deepseek_llm.DeepSeekLLM object at 0x7f544eb43820>
prompt = 'test prompt', args = ()
kwargs = {'messages': [{'role': 'user'}, {'content': 'test'}]}

    @functools.wraps(func)
    async def wrapper(self: Any, prompt: str, *args: Any, **kwargs: Any) -> R:
        if getattr(self, "_skip_state_management", False):
            return await func(self, prompt, *args, **kwargs)
    
        if self._config.history_length == 0:
>           response = await func(self, prompt, [], *args, **kwargs)
E           TypeError: DeepSeekLLM.ask() got multiple values for argument 'messages'

src/providers/llm_history_manager.py:311: TypeError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@Wanbogang
Copy link
Collaborator

@goblin0xcrypto
lint-and-test and unit tests.
Please fix the issues

@goblin0xcrypto goblin0xcrypto force-pushed the test/add-deepseek-llm-coverage branch from ba6a0a9 to 883a076 Compare February 11, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Python code tests Test files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants