def test_get_photo_files_when_image_returned(mock_get, mock_image_file, mock_bytes_io): mock_get.return_value.content = b'some initial binary data: \x00\x01' mock_bytes_io.return_value = b'\x00\x01' result = get_photo_files([{ 'id': '49955674596', 'owner': '128162583@N08', 'secret': 'bb357b3728', 'server': '65535', 'farm': 66, 'title': '_MG_5759', 'ispublic': 1, 'isfriend': 0, 'isfamily': 0, 'o_width': '4632', 'o_height': '2141' }]) mock_bytes_io.assert_called_once_with( b'some initial binary data: \x00\x01') mock_image_file.assert_called_once_with(b'\x00\x01', name='49955674596.jpg') assert isinstance(result, list) assert len(result) == 1
def test_get_photo_files_when_bad_request(mock_get): mock_get.side_effect = requests.exceptions.RequestException result = get_photo_files([{ 'id': '49955674596', 'owner': '128162583@N08', 'secret': 'bb357b3728', 'server': '65535', 'farm': 66, 'title': '_MG_5759', 'ispublic': 1, 'isfriend': 0, 'isfamily': 0, 'o_width': '4632', 'o_height': '2141' }]) assert result is None
def test_get_photo_files_when_none_passed(): result = get_photo_files(None) assert result is None
def test_get_photo_files_when_int_passed(): result = get_photo_files(3) assert result is None
def test_get_photo_files_when_string_passed(): result = get_photo_files('some string') assert result is None
def test_get_photo_files_when_dict_passed(): result = get_photo_files({}) assert result is None
def test_get_photo_files_when_empty_object(): result = get_photo_files([{}]) assert result is None