Skip to content

Add tests for model mapping consistency across all endpoints #676

@nickna

Description

@nickna

Description

Create comprehensive tests to ensure all API endpoints (chat, images, video, audio) consistently use the model mapping service for routing requests to providers.

Background

Recent refactoring work unified the approach to model mappings across all services. Previously, some services (video, audio) were bypassing the model mapping system and directly using the client factory. This has been fixed, but we need tests to ensure consistency is maintained.

Acceptance Criteria

  • Test that chat completions endpoint uses model mappings
  • Test that image generation endpoint uses model mappings
  • Test that video generation endpoint uses model mappings
  • Test that audio transcription endpoint uses model mappings
  • Test that audio translation endpoint uses model mappings
  • Test that realtime audio endpoint uses model mappings
  • Verify error handling when model mapping is not found
  • Test that the correct provider is selected based on mapping
  • Test that provider model name is used (not the alias)

Technical Details

  • Services refactored:

    • AudioRouter.cs - Now uses IModelProviderMappingService
    • VideoGenerationService.cs - Now uses IModelProviderMappingService
    • VideoGenerationOrchestrator.cs - Properly tracks original model alias
  • Key pattern to test:

var modelMapping = await _modelMappingService.GetMappingByModelAliasAsync(request.Model);
if (modelMapping == null)
{
    throw new NotSupportedException($"Model {request.Model} is not configured");
}
var client = _clientFactory.CreateClient(modelMapping.ProviderId);
// Use modelMapping.ProviderModelName for the actual API call

Priority

Medium - Critical for maintaining architectural consistency and preventing regression

Related Issues

  • Part of the usage tracking and cost calculation improvements
  • Follows DRY principle requested by user

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions