Skip to content

Conversation

ArshaanNazir
Copy link

Description

This PR refactors the speech-to-text test suite by introducing new helper methods and comprehensive test cases.

New Test Cases Added

  1. Local File Conversion Test

    • Tests conversion of local audio files
    • Verifies response type and content
    • Uses DEFAULT_VOICE_FILE for testing
  2. External URL Conversion Test

    • Tests conversion of audio from external URLs
    • Handles temporary file creation and cleanup
    • Uses DEFAULT_EXT_AUDIO for testing
  3. Async Conversion Test

    • Tests asynchronous speech-to-text conversion
    • Verifies async client functionality
    • Ensures proper response handling
  4. Model Compatibility Test

    • Tests conversion with different model IDs
    • Currently supports scribe_v1 model
    • Verifies model-specific functionality

New Helper Methods

  1. handle_api_error

    • Centralizes API error handling
    • Provides consistent error handling across tests
  2. convert_audio_file

    • Unified interface for audio conversion
    • Supports both sync and async clients
    • Handles different file input types
  3. download_audio_file

    • Handles external audio file downloads
    • Creates and manages temporary files

assert len(transcription.text) > 0
assert isinstance(transcription.words, list)
assert len(transcription.words) > 0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are more than one trailing newlines, can you make it one

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dr-salman-ahmad Thanks for pointing out. It is done

"""Handle common API error patterns."""
if e.status_code == 401:
pytest.skip("Invalid API key")
raise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use raise e here to correctly propagate the exception.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dr-salman-ahmad Thanks for pointing out. Added it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants