Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DGaffney committed Nov 4, 2023
1 parent 1caca5f commit bc9af91
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/lib/model/test_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_process_audio_success(self, mock_fingerprint_file, mock_request, mock_u
result = self.audio_model.process(audio)
mock_request.assert_called_once_with(audio.body.url, headers={'User-Agent': 'Mozilla/5.0'})
mock_urlopen.assert_called_once_with(mock_request)
self.assertEqual(list, type(result["hash_value"]))
self.assertEqual(list, type(result))

@patch('urllib.request.urlopen')
@patch('urllib.request.Request')
Expand All @@ -49,7 +49,7 @@ def test_process_audio_failure(self, mock_decode_fingerprint, mock_fingerprint_f
result = self.audio_model.process(audio)
mock_request.assert_called_once_with(audio.body.url, headers={'User-Agent': 'Mozilla/5.0'})
mock_urlopen.assert_called_once_with(mock_request)
self.assertEqual([], result["hash_value"])
self.assertEqual([], result)

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion test/lib/model/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_process(self, mock_compute_pdq, mock_get_iobytes_for_image):
mock_get_iobytes_for_image.return_value = io.BytesIO(b"image_bytes")
image = schemas.Message(body=schemas.GenericItem(id="123", callback_url="http://example.com?callback", url="http://example.com/image.jpg"))
result = Model().process(image)
self.assertEqual(result, {"hash_value": "1001"})
self.assertEqual(result, "1001")


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion test/lib/queue/test_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def test_push_message(self):
# Call push_message
returned_message = self.queue.push_message(self.queue_name_output, message_to_push)
# Check if the message was correctly serialized and sent
self.mock_output_queue.send_message.assert_called_once_with(MessageBody='{"body": {"id": "1", "callback_url": "http://example.com", "url": null, "text": "This is a test", "raw": {}}}')
self.mock_output_queue.send_message.assert_called_once_with(MessageBody='{"body": {"id": "1", "callback_url": "http://example.com", "url": null, "text": "This is a test", "raw": {}, "hash_value": null, "bucket": null, "outfile": null}}')

self.assertEqual(returned_message, message_to_push)

if __name__ == '__main__':
Expand Down

0 comments on commit bc9af91

Please sign in to comment.