@@ -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