Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Commit ee320dd

Browse files
committed
added test to make sure that caching works when there is no connection
1 parent 694f72b commit ee320dd

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

tts/test/test_unit_synthesizer.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def test_lost_file(self):
207207
self.assertEqual(audio_file1, audio_file2)
208208
self.assertTrue(os.path.exists(audio_file2))
209209

210-
def test_no_connection(self):
210+
def test_no_connection_novel(self):
211211
from tts.db import DB
212212
from tts.synthesizer import SpeechSynthesizer
213213
from tts.srv import SynthesizerRequest
@@ -224,6 +224,31 @@ def test_no_connection(self):
224224

225225
self.assertEqual(db.get_num_files(), init_num_files)
226226

227+
def test_no_connection_existing(self):
228+
from tts.db import DB
229+
from tts.synthesizer import SpeechSynthesizer
230+
from tts.srv import SynthesizerRequest
231+
import uuid
232+
import json
233+
234+
target_text = uuid.uuid4().hex
235+
236+
speech_synthesizer = SpeechSynthesizer(engine='DUMMY')
237+
request = SynthesizerRequest(text=target_text, metadata={})
238+
response = speech_synthesizer._node_request_handler(request)
239+
res_dict = json.loads(response.result)
240+
audio_file1 = res_dict['Audio File']
241+
242+
speech_synthesizer.engine.set_connection(False)
243+
244+
speech_synthesizer = SpeechSynthesizer(engine='DUMMY')
245+
request = SynthesizerRequest(text=target_text, metadata={})
246+
response = speech_synthesizer._node_request_handler(request)
247+
res_dict = json.loads(response.result)
248+
audio_file2 = res_dict['Audio File']
249+
250+
self.assertEqual(audio_file1, audio_file2)
251+
227252
def test_file_cleanup(self):
228253
from tts.db import DB
229254
from tts.synthesizer import SpeechSynthesizer

0 commit comments

Comments
 (0)