Implement support for segments with an optional categories key
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
from audita.core.schemas import parse_source_transcript_json, parse_transcript_json
|
||||
import json
|
||||
|
||||
from audita.core.schemas import parse_source_transcript_json, parse_transcript_json, transcript_to_json
|
||||
|
||||
|
||||
SERIATIM_TRANSCRIPT = """
|
||||
@@ -60,6 +62,8 @@ def test_parse_source_transcript_json_accepts_seriatim_transcript_object():
|
||||
assert segments[0].end == 3.5
|
||||
assert segments[0].text == "Hello there."
|
||||
assert segments[1].text == "Resolved word run"
|
||||
assert segments[0].categories is None
|
||||
assert segments[1].categories == ["backchannel"]
|
||||
|
||||
|
||||
def test_parse_transcript_json_accepts_seriatim_transcript_object_and_ignores_unused_fields():
|
||||
@@ -67,3 +71,14 @@ def test_parse_transcript_json_accepts_seriatim_transcript_object_and_ignores_un
|
||||
|
||||
assert [segment.id for segment in segments] == [1, 2]
|
||||
assert [segment.text for segment in segments] == ["Hello there.", "Resolved word run"]
|
||||
assert segments[0].categories is None
|
||||
assert segments[1].categories == ["backchannel"]
|
||||
|
||||
|
||||
def test_transcript_to_json_emits_categories_only_when_present():
|
||||
segments = parse_transcript_json(SERIATIM_TRANSCRIPT)
|
||||
|
||||
payload = json.loads(transcript_to_json(segments))
|
||||
|
||||
assert "categories" not in payload[0]
|
||||
assert payload[1]["categories"] == ["backchannel"]
|
||||
|
||||
Reference in New Issue
Block a user