diff --git a/core/src/zeit/speech/testing.py b/core/src/zeit/speech/testing.py index 0292884d9c..ca4fee0e24 100644 --- a/core/src/zeit/speech/testing.py +++ b/core/src/zeit/speech/testing.py @@ -24,13 +24,13 @@ TTS_CREATION_STARTED = { 'event': 'AUDIO_CREATION_STARTED', 'uuid': 'a89ce2e3-4887-466a-a52e-edc6b9802ef9', - 'checksum': 'd751713988987e9331980363e24189ce', + 'checksum': '54436411ba2288d0db073246c85e0f09', } TTS_CREATION_FAILED = { 'event': 'AUDIO_CREATION_FAILED', 'uuid': 'a89ce2e3-4887-466a-a52e-edc6b9802ef9', - 'checksum': 'd751713988987e9331980363e24189ce', + 'checksum': '54436411ba2288d0db073246c85e0f09', 'reason': 'AudioStream must be a Buffer', } @@ -40,7 +40,7 @@ 'articlesAudio': [ { 'type': 'FULL_TTS', - 'checksum': 'd751713988987e9331980363e24189ce', + 'checksum': '54436411ba2288d0db073246c85e0f09', 'audioEntry': { 'uuid': 'e7fba272-c442-4cde-a5c9-3d75a89e5273', 'url': 'https://zon-speechbert/articles/a89ce2e3-4887-466a-a52e-edc6b9802ef9/full_1fd74183d02f50d5cd0731a5748019e95bbe68bd71f33cbd2c03c4d64c8a1d91a7f25f6725db6b19348bd94af09fc563.mp3', @@ -49,7 +49,7 @@ }, { 'type': 'PREVIEW_TTS', - 'checksum': 'd751713988987e9331980363e24189ce', + 'checksum': '54436411ba2288d0db073246c85e0f09', 'audioEntry': { 'uuid': '58ff08f4-cef5-45eb-a980-064bd78c42df', 'url': 'https://zon-speechbert/articles/a89ce2e3-4887-466a-a52e-edc6b9802ef9/preview_1fd74183d02f50d5cd0731a5748019e95bbe68bd71f33cbd2c03c4d64c8a1d91a7f25f6725db6b19348bd94af09fc563.mp3', @@ -83,8 +83,8 @@ def setUp(self): self.unique_id = ( f'http://xml.zeit.de/tts/{current_date.strftime("%Y-%m")}/{TTS_CREATED["uuid"]}' ) - self.article = ICMSContent('http://xml.zeit.de/online/2007/01/Somalia') - self.article_uid = 'http://xml.zeit.de/online/2007/01/Somalia' + self.article_uid = 'http://xml.zeit.de/online/2022/08/trockenheit' + self.article = ICMSContent(self.article_uid) IPublishInfo(self.article).urgent = True IPublish(self.article).publish(background=False) diff --git a/core/src/zeit/speech/tests/test_connection.py b/core/src/zeit/speech/tests/test_connection.py index e6afcefb6b..30b251d0f8 100644 --- a/core/src/zeit/speech/tests/test_connection.py +++ b/core/src/zeit/speech/tests/test_connection.py @@ -1,5 +1,4 @@ from unittest import mock -import copy import pytest import zope.security.management @@ -32,28 +31,27 @@ def test_message_audio_created(self): ) assert IPublishInfo(audio).published, 'Publish you fool!' - def _setup_speech_message(self, field, value): - tts_created = copy.deepcopy(TTS_CREATED) - tts_created['articlesAudio'][0][field] = value - return tts_created - def test_update_existing_tts_audio(self): audio = self.create_audio(TTS_CREATED) created_time = ISemanticChange(audio).last_semantic_change assert ISpeechInfo(audio).checksum == TTS_CREATED['articlesAudio'][0]['checksum'] - self.repository.connector.search_result = [(audio.uniqueId)] - tts_msg = self.setup_speech_message('checksum', 'cookiesandcake') - Speech().update(tts_msg) + self.repository.connector.search_result = [(self.article.uniqueId)] + tts_msg = self.setup_speech_message( + 'audioEntry', {'url': 'http://example.com/cats.mp3', 'duration': 1000} + ) + with mock.patch('zeit.speech.connection.Speech._find', return_value=audio): + Speech().update(tts_msg) updated_time = ISemanticChange(audio).last_semantic_change assert updated_time > created_time, 'Semantic time should be updated' - assert ISpeechInfo(audio).checksum == 'cookiesandcake', 'Update your checksum' + audio = ICMSContent(self.unique_id) + assert audio.duration == 1 def test_update_broken_audio_repairs_reference_to_article(self): + self.repository.connector.search_result = [(self.article.uniqueId)] audio = Speech()._create(TTS_CREATED) IPublish(audio).publish(background=False) assert ICMSContent(self.unique_id) assert not IAudioReferences(ICMSContent(self.article_uid)).items - self.repository.connector.search_result = [(self.article.uniqueId)] with mock.patch('zeit.speech.connection.Speech._find', return_value=audio): Speech().update(TTS_CREATED) assert IAudioReferences(ICMSContent(self.article_uid)).items == (audio,)