def test_list_images(self, mock_isfile, mock_listdir): """ Test that our directory/file finding works appropriately """ settings.KITTEH_IMAGES_PATH = 'path' mock_listdir.return_value = ['01.jpg'] mock_isfile.return_value = True form = LocalPlaceholderForm({'height': '400', 'width': '400'}) result = form.list_images() # Ensure that 'source/'is prepended to '01.jpg' as returned self.assertEqual(['source/01.jpg'], result)
def test_get_image(self, mock_open): """ Test that the image path manipulation is as expectd """ settings.KITTEH_IMAGES_PATH = 'path' form = LocalPlaceholderForm({'height': '400', 'width': '400'}) form.get_image('source/01.jpg') mock_open.assert_called_with('path/source/01.jpg')