ahczhg's picture
Upload 14 files
360a82f verified

Testing Framework

Overview

This directory contains comprehensive tests for the Advanced Sentiment Analysis System.

Test Structure

tests/
β”œβ”€β”€ __init__.py
β”œβ”€β”€ conftest.py              # pytest configuration and fixtures
β”œβ”€β”€ test_sentiment_analysis.py  # Core sentiment analysis tests
β”œβ”€β”€ test_api.py              # API endpoint tests
β”œβ”€β”€ test_security.py         # Security and validation tests
β”œβ”€β”€ test_performance.py      # Performance and load tests
β”œβ”€β”€ integration/             # Integration tests
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── test_end_to_end.py
└── fixtures/                # Test data and fixtures
    β”œβ”€β”€ sample_texts.json
    └── expected_results.json

Running Tests

All Tests

pytest tests/

With Coverage

pytest tests/ --cov=./ --cov-report=html

Specific Test Categories

# Unit tests only
pytest tests/test_*.py

# Integration tests
pytest tests/integration/

# Performance tests
pytest tests/test_performance.py -v

Test Categories

Unit Tests

  • Sentiment analysis accuracy
  • DSPy module functionality
  • Data preprocessing
  • Error handling

Integration Tests

  • End-to-end workflow
  • API integration
  • Database operations
  • External service integration

Performance Tests

  • Response time benchmarks
  • Memory usage validation
  • Concurrent request handling
  • Scalability testing

Security Tests

  • Input validation
  • API key protection
  • Rate limiting
  • Data sanitization

Fixtures and Mock Data

Test fixtures are located in tests/fixtures/ and include:

  • Sample text data for various sentiment scenarios
  • Expected analysis results
  • Mock API responses
  • Test configuration data

Continuous Integration

Tests are automatically run on:

  • Every push to main/develop branches
  • Pull request creation
  • Scheduled nightly runs

Coverage Requirements

Minimum coverage thresholds:

  • Overall: 85%
  • Critical modules: 90%
  • API endpoints: 95%