Skip to content

Commit

Permalink
Update test_downsampled_image_creation
Browse files Browse the repository at this point in the history
  • Loading branch information
zoeduan committed Jul 28, 2024
1 parent c527cec commit 279ea43
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions tests/test_download_images.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from unittest.mock import patch, MagicMock, mock_open, call
from unittest.mock import patch, MagicMock, mock_open, call
import pandas as pd
import os
import io
Expand Down Expand Up @@ -84,17 +84,12 @@ def test_failure_after_retries(self, get_mock):
for filename in self.DUMMY_DATA['filename']:
self.assertFalse(os.path.isfile(f"{self.IMG_DIR}/{filename}"))

@patch('requests.get')
@patch('PIL.Image.open')
def test_downsampled_image_creation(self, open_mock, get_mock):
@patch('cautiousrobot.__main__.requests.get')
def test_downsampled_image_creation(self,get_mock):
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.raw = BytesIO(b"fake_image_data")
mock_response.content = b'dummy_image_data'
get_mock.return_value = mock_response

img_mock = MagicMock()
open_mock.return_value = img_mock

download_images(self.DUMMY_DATA, self.IMG_DIR, self.LOG_FILEPATH, self.ERROR_LOG_FILEPATH,
downsample_path=self.DOWNSAMPLE_PATH, downsample=self.DOWNSAMPLE_SIZE)

Expand Down

0 comments on commit 279ea43

Please sign in to comment.