def test_crop_image(self, mock_image_open):
        mock_crop_image = mock.Mock()
        mock_base_image = mock.Mock(crop=mock.Mock(return_value=mock_crop_image))
        mock_base_image.resize.return_value = mock_base_image
        mock_image_open.return_value = mock_base_image
        file_path = 'abc.jpeg'

        crop_image(file_path, 1, 2, 3, 4)
        mock_image_open.assert_called_once_with(file_path)
        mock_base_image.crop.assert_called_once_with((1, 2, 4, 6))
        mock_base_image.resize.assert_called_once_with(mock_crop_image.size)
        mock_base_image.paste.assert_called_once_with(mock_crop_image)
        mock_base_image.save.assert_called_once_with(file_path)
    def capture_feed_to_file(self, file_path):
        """
        Capture document info, include author info and document info
        """
        self._fetch_url()
        self._wait_feed_load_complete()

        document_info_selector = '#plc_main'
        info_location = self.find_element(document_info_selector).location

        document_handle_selector = '.WB_feed_handle'
        handler = self.find_element(document_handle_selector)
        handler_location = handler.location
        handler_size = handler.size

        self.screen_shot(file_path)
        utils.crop_image(file_path,
                         info_location['x'] - 3,
                         info_location['y'] - 3,
                         handler_size['width'] + 6,
                         handler_location['y'] + handler_size['height'] - info_location['y'] + 6)