Add diarization and reusable MVP meeting pipeline
This commit is contained in:
@@ -11,8 +11,10 @@ from src.meeting_lab.extraction.extract_chunks import (
|
||||
)
|
||||
from src.meeting_lab.models.meeting_context import (
|
||||
MeetingContextValidationError,
|
||||
create_meeting_context,
|
||||
load_meeting_context,
|
||||
render_meeting_context_for_prompt,
|
||||
serialize_meeting_context_yaml,
|
||||
validate_meeting_context,
|
||||
)
|
||||
|
||||
@@ -192,6 +194,51 @@ class MeetingContextTests(unittest.TestCase):
|
||||
self.assertNotIn("responsible: Björn", prompt_context)
|
||||
self.assertNotIn("responsible: Jovana", prompt_context)
|
||||
|
||||
def test_existing_context_without_speaker_mappings_remains_valid(self) -> None:
|
||||
self.assertEqual(self.context.speaker_mappings, {})
|
||||
self.assertIsNone(self.context.participant_for_speaker("SPEAKER_00"))
|
||||
|
||||
def test_explicit_speaker_mapping_is_authoritative(self) -> None:
|
||||
data = copy.deepcopy(self.context.data)
|
||||
participant = data["participants"][0]
|
||||
data["speaker_mappings"] = {"SPEAKER_03": participant["participant_id"]}
|
||||
|
||||
context = create_meeting_context(data)
|
||||
rendered = render_meeting_context_for_prompt(context)
|
||||
|
||||
self.assertEqual(
|
||||
context.participant_for_speaker("SPEAKER_03")["participant_id"],
|
||||
participant["participant_id"],
|
||||
)
|
||||
self.assertIsNone(context.participant_for_speaker("SPEAKER_04"))
|
||||
self.assertIn("Confirmed diarization speaker mappings (authoritative)", rendered)
|
||||
self.assertIn("Unmapped SPEAKER_XX labels must remain anonymous", rendered)
|
||||
|
||||
def test_speaker_mapping_must_reference_existing_participant(self) -> None:
|
||||
data = copy.deepcopy(self.context.data)
|
||||
data["speaker_mappings"] = {"SPEAKER_00": "unknown-person"}
|
||||
with self.assertRaisesRegex(MeetingContextValidationError, "unknown participant"):
|
||||
validate_meeting_context(data)
|
||||
|
||||
def test_speaker_mapping_label_must_use_pyannote_shape(self) -> None:
|
||||
data = copy.deepcopy(self.context.data)
|
||||
data["speaker_mappings"] = {
|
||||
"Martin": data["participants"][0]["participant_id"]
|
||||
}
|
||||
with self.assertRaisesRegex(MeetingContextValidationError, "speaker label"):
|
||||
validate_meeting_context(data)
|
||||
|
||||
def test_generated_context_yaml_is_deterministic_and_round_trips(self) -> None:
|
||||
first = serialize_meeting_context_yaml(self.context)
|
||||
second = serialize_meeting_context_yaml(self.context)
|
||||
self.assertEqual(first, second)
|
||||
|
||||
SCRATCH_DIR.mkdir(exist_ok=True)
|
||||
path = SCRATCH_DIR / "generated_context.yaml"
|
||||
path.write_text(first, encoding="utf-8")
|
||||
loaded = load_meeting_context(path)
|
||||
self.assertEqual(loaded.data, self.context.data)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user