Skip to content

Commit 5dfa373

Browse files
committed
tests updated
1 parent 3ee2135 commit 5dfa373

File tree

3 files changed

+80
-21
lines changed

3 files changed

+80
-21
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ PyJWT==2.9.0
2222
cryptography==43.0.1
2323
psutil==7.0.0
2424
openai==1.98.0
25+
pytest-asyncio==0.21.0

test/exporters/test_text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_error_handling_no_content(self, text_exporter, mock_transcript):
6060
text_exporter.export(mock_transcript)
6161

6262
# Check the error message
63-
assert "No transcript content found" in str(excinfo.value)
63+
assert "No content found for key: raw" in str(excinfo.value)
6464

6565
def test_output_directory_creation(self, temp_dir, mock_transcript):
6666
"""Test that the exporter creates output directories as needed"""

test/integration/test_transcription_exporters.py

Lines changed: 78 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,18 @@ def test_write_to_markdown_file(
8282
# Check the result
8383
assert result == "/path/to/exported/markdown.md"
8484

85-
def test_postprocess_with_markdown(
85+
def test_export_with_markdown(
8686
self, transcription_with_exporters, mock_transcript
8787
):
88-
"""Test postprocess with markdown output"""
88+
"""Test export with markdown output"""
8989
# Mock the write_to_markdown_file method to avoid calling the exporter directly
9090
transcription_with_exporters.write_to_markdown_file = mock.MagicMock()
9191
transcription_with_exporters.write_to_markdown_file.return_value = (
9292
"/path/to/exported/markdown.md"
9393
)
9494

95-
# Call postprocess
96-
transcription_with_exporters.postprocess(mock_transcript)
95+
# Call export
96+
transcription_with_exporters.export(mock_transcript)
9797

9898
# Check that write_to_markdown_file was called
9999
transcription_with_exporters.write_to_markdown_file.assert_called_once()
@@ -104,13 +104,13 @@ def test_postprocess_with_markdown(
104104
== "/path/to/exported/markdown.md"
105105
)
106106

107-
def test_postprocess_with_text(
107+
def test_export_with_text(
108108
self,
109109
transcription_with_exporters,
110110
mock_transcript,
111111
mock_transcription_deps,
112112
):
113-
"""Test postprocess with text output"""
113+
"""Test export with text output"""
114114
# Get the mock exporters
115115
exporters = mock_transcription_deps[
116116
"ExporterFactory"
@@ -126,23 +126,17 @@ def test_postprocess_with_text(
126126
"/path/to/exported/markdown.md"
127127
)
128128

129-
# Call postprocess
130-
transcription_with_exporters.postprocess(mock_transcript)
129+
# Call export
130+
transcription_with_exporters.export(mock_transcript)
131131

132132
# Check that the text exporter was called
133-
text_exporter.export.assert_called_once()
133+
text_exporter.export.assert_called()
134134
assert text_exporter.export.call_args[1]["add_timestamp"] is False
135135

136-
# Check that the output was stored in the transcript
137-
assert (
138-
mock_transcript.outputs["text"]
139-
== "/path/to/exported/transcript.txt"
140-
)
141-
142-
def test_postprocess_with_json(
136+
def test_export_with_json(
143137
self, transcription_with_exporters, mock_transcript, mock_transcription_deps
144138
):
145-
"""Test postprocess with JSON output"""
139+
"""Test export with JSON output"""
146140
# Get the mock exporters
147141
exporters = mock_transcription_deps[
148142
"ExporterFactory"
@@ -158,8 +152,8 @@ def test_postprocess_with_json(
158152
"/path/to/exported/markdown.md"
159153
)
160154

161-
# Call postprocess
162-
transcription_with_exporters.postprocess(mock_transcript)
155+
# Call export
156+
transcription_with_exporters.export(mock_transcript)
163157

164158
# Check that the json exporter was called
165159
json_exporter.export.assert_called_once()
@@ -168,4 +162,68 @@ def test_postprocess_with_json(
168162
assert (
169163
mock_transcript.outputs["json"]
170164
== "/path/to/exported/transcript.json"
171-
)
165+
)
166+
167+
def test_export_with_all_outputs(
168+
self,
169+
transcription_with_exporters,
170+
mock_transcript,
171+
mock_transcription_deps,
172+
):
173+
"""Test export with all outputs enabled"""
174+
# Get mock exporters
175+
exporters = mock_transcription_deps[
176+
"ExporterFactory"
177+
].create_exporters.return_value
178+
text_exporter = exporters["text"]
179+
json_exporter = exporters["json"]
180+
181+
# Set up return values
182+
text_exporter.export.return_value = "/path/to/text.txt"
183+
json_exporter.export.return_value = "/path/to/json.json"
184+
185+
# Mock write_to_markdown_file
186+
transcription_with_exporters.write_to_markdown_file = mock.MagicMock()
187+
transcription_with_exporters.write_to_markdown_file.return_value = (
188+
"/path/to/markdown.md"
189+
)
190+
191+
# Call export
192+
transcription_with_exporters.export(mock_transcript)
193+
194+
# Check that all exporters were called
195+
text_exporter.export.assert_called()
196+
json_exporter.export.assert_called_once()
197+
transcription_with_exporters.write_to_markdown_file.assert_called_once()
198+
199+
# Check that all outputs are stored
200+
assert mock_transcript.outputs["json"] == "/path/to/json.json"
201+
assert mock_transcript.outputs["markdown"] == "/path/to/markdown.md"
202+
203+
def test_export_no_outputs(
204+
self, patched_transcription, mock_transcript, mock_transcription_deps
205+
):
206+
"""Test export with no outputs enabled"""
207+
# Create a Transcription instance with all export options disabled
208+
transcription = Transcription(
209+
markdown=False, text_output=False, json=False, username="Test User"
210+
)
211+
transcription.exporters.clear()
212+
213+
# Clear the mock transcript's outputs and add back the raw output
214+
mock_transcript.outputs.clear()
215+
mock_transcript.outputs['raw'] = 'test transcript'
216+
217+
# Mock write_to_markdown_file
218+
transcription.write_to_markdown_file = mock.MagicMock()
219+
220+
# Call export
221+
transcription.export(mock_transcript)
222+
223+
# Check that no exporters were called
224+
transcription.write_to_markdown_file.assert_not_called()
225+
226+
# Check that no outputs were stored
227+
assert "text" not in mock_transcript.outputs
228+
assert "json" not in mock_transcript.outputs
229+
assert "markdown" not in mock_transcript.outputs

0 commit comments

Comments
 (0)