Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DGaffney committed Jun 18, 2024
1 parent 5dd53ef commit a6dc857
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions test/lib/model/test_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,23 @@ def test_tmk_program_name(self):
result = self.video_model.tmk_program_name()
self.assertEqual(result, "PrestoVideoEncoder")

def test_respond_with_single_video(self):
@patch('lib.cache.Cache.get_cached_result')
@patch('lib.cache.Cache.set_cached_result')
def test_respond_with_single_video(self, mock_cache_set, mock_cache_get):
mock_cache_get.return_value = None
mock_cache_set.return_value = True
video = schemas.parse_message({"body": {"id": "123", "callback_url": "http://blah.com?callback_id=123", "url": "http://example.com/video.mp4"}, "model_name": "video__Model"})
mock_process = MagicMock()
self.video_model.process = mock_process
result = self.video_model.respond(video)
mock_process.assert_called_once_with(video)
self.assertEqual(result, [video])

@patch('lib.cache.Cache')
def test_respond_with_multiple_videos(self, mock_cache):
mock_cache.get_cached_result.return_value = None
mock_cache.set_cached_result.return_value = True
@patch('lib.cache.Cache.get_cached_result')
@patch('lib.cache.Cache.set_cached_result')
def test_respond_with_multiple_videos(self, mock_cache_set, mock_cache_get):
mock_cache_get.return_value = None
mock_cache_set.return_value = True
videos = [schemas.parse_message({"body": {"id": "123", "callback_url": "http://blah.com?callback_id=123", "url": "http://example.com/video.mp4"}, "model_name": "video__Model"}), schemas.parse_message({"body": {"id": "123", "callback_url": "http://blah.com?callback_id=123", "url": "http://example.com/video2.mp4"}, "model_name": "video__Model"})]
mock_process = MagicMock()
self.video_model.process = mock_process
Expand Down
2 changes: 1 addition & 1 deletion test/lib/queue/test_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_push_to_dead_letter_queue(self):
# Call push_to_dead_letter_queue
self.queue.push_to_dead_letter_queue(message_to_push)
# Check if the message was correctly serialized and sent to the DLQ
self.mock_dlq_queue.send_message.assert_called_once_with(MessageBody='{"body": {"id": 1,"content_hash": null, "callback_url": "http://example.com", "url": null, "text": "This is a test", "raw": {}, "parameters": {}, "result": {"hash_value": null}}, "model_name": "mean_tokens__Model", "retry_count": 0}')
self.mock_dlq_queue.send_message.assert_called_once_with(MessageBody='{"body": {"id": 1, "content_hash": null, "callback_url": "http://example.com", "url": null, "text": "This is a test", "raw": {}, "parameters": {}, "result": {"hash_value": null}}, "model_name": "mean_tokens__Model", "retry_count": 0}')

def test_increment_message_error_counts_exceed_max_retries(self):
message_body = {
Expand Down

0 comments on commit a6dc857

Please sign in to comment.