Fix ChatPromptTemplate variable parsing issue and update tests
- Replace ChatPromptTemplate with direct HumanMessage/SystemMessage to avoid template variable parsing - Fix f-string formatting issues in prompt strings - Update test_general_summary_fallback_on_error to properly mock fallback chain - Add tests directory with comprehensive test coverage
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
"""
|
||||
Shared fixtures and configuration for tests
|
||||
"""
|
||||
import pytest
|
||||
import os
|
||||
from unittest.mock import Mock, MagicMock
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_anthropic_api_key():
|
||||
"""Mock Anthropic API key for testing"""
|
||||
return "test-api-key-12345"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_transcription_dict():
|
||||
"""Sample transcription dictionary for testing"""
|
||||
return {
|
||||
"sentences": [
|
||||
{
|
||||
"text": "Hello, welcome to the meeting.",
|
||||
"start": 0.5,
|
||||
"end": 3.2,
|
||||
"speaker": "Speaker_A",
|
||||
"words": [
|
||||
{"word": "Hello", "start": 0.5, "end": 0.8},
|
||||
{"word": "welcome", "start": 0.9, "end": 1.3},
|
||||
{"word": "to", "start": 1.4, "end": 1.5},
|
||||
{"word": "the", "start": 1.6, "end": 1.7},
|
||||
{"word": "meeting", "start": 1.8, "end": 2.3}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "Let's discuss the project timeline.",
|
||||
"start": 4.0,
|
||||
"end": 7.5,
|
||||
"speaker": "Speaker_B",
|
||||
"words": [
|
||||
{"word": "Let's", "start": 4.0, "end": 4.3},
|
||||
{"word": "discuss", "start": 4.4, "end": 5.0},
|
||||
{"word": "the", "start": 5.1, "end": 5.2},
|
||||
{"word": "project", "start": 5.3, "end": 5.8},
|
||||
{"word": "timeline", "start": 5.9, "end": 6.5}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_basic_summary_response():
|
||||
"""Sample basic summary response (freemium plan)"""
|
||||
return {
|
||||
"Key_Points": [
|
||||
{"text": "Team discussed project timeline.", "timestamp": 4.0},
|
||||
{"text": "Meeting started with introductions.", "timestamp": 0.5}
|
||||
],
|
||||
"Summary": {
|
||||
"text": "Brief meeting to discuss project timeline and introductions.",
|
||||
"duration_minutes": 7.5
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_advanced_summary_response():
|
||||
"""Sample advanced summary response (pro plan)"""
|
||||
return {
|
||||
"Purpose": {
|
||||
"text": "Discuss project timeline and team introductions."
|
||||
},
|
||||
"Chapters": {
|
||||
"minutes_total": 0.125,
|
||||
"content": [
|
||||
{
|
||||
"chapter": "Introduction",
|
||||
"time_stamp": {"start": 0.5, "end": 3.2},
|
||||
"content": [
|
||||
{
|
||||
"text": "- Welcome to the meeting.",
|
||||
"original_transcript_start": 0.5,
|
||||
"original_transcript_end": 3.2
|
||||
}
|
||||
],
|
||||
"words_time_stamp": [
|
||||
{"word": "Introduction", "timestamp": 0.5}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"Outcomes": {
|
||||
"minutes_total": 0.125,
|
||||
"content": [
|
||||
{
|
||||
"text": "Project timeline discussed.",
|
||||
"time_stamp": {"start": 4.0, "end": 7.5},
|
||||
"words_time_stamp": [
|
||||
{"word": "Project", "timestamp": 4.0},
|
||||
{"word": "timeline", "timestamp": 4.0}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"Action_Items_Per_User": [
|
||||
{
|
||||
"speaker": "Speaker_B",
|
||||
"minutes_total": 0.125,
|
||||
"action_items": [
|
||||
{
|
||||
"text": "Review project timeline.",
|
||||
"time_stamp": {"start": 4.0, "end": 7.5},
|
||||
"words_time_stamp": [
|
||||
{"word": "Review", "timestamp": 4.0}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_template():
|
||||
"""Sample custom template"""
|
||||
return {
|
||||
"Key_Points": "Summarize the most critical discussion points from the meeting.",
|
||||
"Summary": "Provide a brief overall summary of what was discussed.",
|
||||
"Next_Steps": "List the next steps decided during the meeting."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user