Address all review comments: fix test counts, remove unused imports, improve workflow

Co-authored-by: Kenearos <86194771+Kenearos@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-01-03 10:59:56 +00:00
parent 0411d0856a
commit 6bb006fbe1
4 changed files with 29 additions and 32 deletions

View file

@ -38,13 +38,19 @@ jobs:
run: | run: |
pytest tests/ -v --cov=. --cov-report=xml --cov-report=term-missing pytest tests/ -v --cov=. --cov-report=xml --cov-report=term-missing
- name: Generate .coverage file
if: matrix.python-version == '3.11'
run: |
coverage run -m pytest tests/
- name: Upload coverage to Codecov - name: Upload coverage to Codecov
uses: codecov/codecov-action@v4 uses: codecov/codecov-action@v4
with: with:
file: ./coverage.xml file: ./coverage.xml
flags: unittests flags: unittests
name: codecov-umbrella name: codecov-umbrella
fail_ci_if_error: false fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
- name: Generate coverage badge - name: Generate coverage badge
if: matrix.python-version == '3.11' if: matrix.python-version == '3.11'
@ -94,4 +100,3 @@ jobs:
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# Exit-zero treats all errors as warnings # Exit-zero treats all errors as warnings
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
continue-on-error: true

View file

@ -105,30 +105,25 @@ tests/
## Test Statistics ## Test Statistics
- **Total Tests**: 173 (+57 from initial 116) - **Total Tests**: 173 tests (up from 116)
- **Passing**: 173 (100%) - **Passing**: 173 (100%)
- **Code Coverage**: 100% (up from 97%) - **Code Coverage**: 100% (up from 97%)
- **Test Execution Time**: ~1.1 seconds - **Test Execution Time**: ~1.1 seconds
## Test Breakdown ## Test Breakdown
- **Unit Tests**: 156 tests - **Unit Tests**: 163 tests
- MentionDetector: 73 tests (including 45 parameterized) - MentionDetector: 84 tests (including 45 parameterized)
- Logger: 16 tests - Logger: 16 tests
- ConversationMemory: 28 tests - ConversationMemory: 28 tests
- PerplexityProvider: 22 tests - PerplexityProvider: 22 tests
- Config: 27 tests - Config: 29 tests
- **Integration Tests**: 9 tests - **Integration Tests**: 10 tests
- Full workflow testing - Full workflow testing
- Component interaction - Component interaction
- Error recovery scenarios - Error recovery scenarios
- **Parameterized Tests**: 45 tests
- Mention detection patterns
- Greeting detection
- Content extraction
## Improvements from Initial Version ## Improvements from Initial Version
**100% code coverage** (was 97%) **100% code coverage** (was 97%)

View file

@ -3,8 +3,7 @@ Integration tests for Eugen Bot
Tests the full workflow and component integration Tests the full workflow and component integration
""" """
import pytest import pytest
import asyncio from unittest.mock import Mock, AsyncMock, patch
from unittest.mock import Mock, AsyncMock, patch, MagicMock
from config import Config from config import Config
from memory import ConversationMemory from memory import ConversationMemory
from ai_provider import PerplexityProvider from ai_provider import PerplexityProvider
@ -71,7 +70,6 @@ class TestFullWorkflow:
"""Test that conversation context is preserved across messages""" """Test that conversation context is preserved across messages"""
config = Config(env_file=str(mock_env_file), config_file=str(temp_dir / "config.json")) config = Config(env_file=str(mock_env_file), config_file=str(temp_dir / "config.json"))
memory = ConversationMemory(data_dir=str(temp_dir / "conversations")) memory = ConversationMemory(data_dir=str(temp_dir / "conversations"))
ai = PerplexityProvider(api_key=config.perplexity_key)
username = "testuser" username = "testuser"
@ -175,7 +173,6 @@ class TestFullWorkflow:
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_memory_limit_enforcement_in_workflow(self, temp_dir, mock_env_file): async def test_memory_limit_enforcement_in_workflow(self, temp_dir, mock_env_file):
"""Test that memory limits are enforced during conversation""" """Test that memory limits are enforced during conversation"""
config = Config(env_file=str(mock_env_file), config_file=str(temp_dir / "config.json"))
memory = ConversationMemory( memory = ConversationMemory(
data_dir=str(temp_dir / "conversations"), data_dir=str(temp_dir / "conversations"),
max_messages=10 max_messages=10
@ -266,11 +263,12 @@ class TestComponentInteraction:
# Create complete config # Create complete config
complete_env = temp_dir / "complete.env" complete_env = temp_dir / "complete.env"
complete_env.write_text("""TWITCH_OAUTH_TOKEN=oauth:test123 complete_env.write_text(
TWITCH_CHANNEL=#testchannel "TWITCH_OAUTH_TOKEN=oauth:test123\n"
TWITCH_BOT_NICKNAME=TestBot "TWITCH_CHANNEL=#testchannel\n"
PERPLEXITY_API_KEY=pplx-test123 "TWITCH_BOT_NICKNAME=TestBot\n"
""") "PERPLEXITY_API_KEY=pplx-test123\n"
)
config2 = Config(env_file=str(complete_env), config_file=str(temp_dir / "config.json")) config2 = Config(env_file=str(complete_env), config_file=str(temp_dir / "config.json"))

View file

@ -2,7 +2,6 @@
Tests for utility classes: MentionDetector and Logger Tests for utility classes: MentionDetector and Logger
""" """
import pytest import pytest
from pathlib import Path
import logging import logging
from utils import MentionDetector, Logger from utils import MentionDetector, Logger
@ -20,7 +19,7 @@ MENTION_TEST_CASES = [
("Eugen. listen", "Eugen", True, "period format"), ("Eugen. listen", "Eugen", True, "period format"),
("Hey Eugen how are you", "Eugen", True, "mention in middle"), ("Hey Eugen how are you", "Eugen", True, "mention in middle"),
("Is Eugen online?", "Eugen", True, "mention as word"), ("Is Eugen online?", "Eugen", True, "mention as word"),
("Eugene is different", "Eugen", False, "partial match should fail"), ("Eugene is different", "Eugen", False, "name as substring of longer word should fail"),
("Eugenics is a topic", "Eugen", False, "false positive check"), ("Eugenics is a topic", "Eugen", False, "false positive check"),
("Regular message", "Eugen", False, "no mention"), ("Regular message", "Eugen", False, "no mention"),
("@kenearosmd hi", "kenearosmd", True, "long name at-mention"), ("@kenearosmd hi", "kenearosmd", True, "long name at-mention"),
@ -436,18 +435,18 @@ class TestLogger:
def test_logger_reuses_existing_handlers(self, temp_dir): def test_logger_reuses_existing_handlers(self, temp_dir):
"""Test that logger doesn't create duplicate handlers""" """Test that logger doesn't create duplicate handlers"""
import logging
log_dir = temp_dir / "logs" log_dir = temp_dir / "logs"
# Create first logger # Create first logger instance to set up handlers
logger1 = Logger(log_dir=str(log_dir), debug_mode=True) Logger(log_dir=str(log_dir), debug_mode=True)
handler_count_1 = len(logger1.main_logger.handlers) main_logger_1 = logging.getLogger("eugen_main")
handler_count_1 = len(main_logger_1.handlers)
# Create second logger with same settings - should reuse handlers # Create second logger with same settings - should not add handlers
logger2 = Logger(log_dir=str(log_dir), debug_mode=True) Logger(log_dir=str(log_dir), debug_mode=True)
handler_count_2 = len(logger2.main_logger.handlers) main_logger_2 = logging.getLogger("eugen_main")
handler_count_2 = len(main_logger_2.handlers)
# Should have same number of handlers (reused, not duplicated) # Underlying logger should have the same number of handlers (reused, not duplicated)
assert handler_count_1 == handler_count_2 assert handler_count_1 == handler_count_2
assert handler_count_1 > 0 # But should have at least one handler assert handler_count_1 > 0 # But should have at least one handler