Esempio n. 1
0
def batch_downloader(file):
    """
    Takes a text file and scrapes the image URLs
    """
    images = ImagesDownload(fileName = file)
    dirName, imageBookPath = images.filePath()
    imageBookData = images.readFile(imageBookPath)
    images.downloadImages(dirName, imageBookData)
class TestImageDownloader(unittest.TestCase, ImagesDownload):

	def setUp(self):
		self.images = ImagesDownload(fileName = None)
		self.mock_data = ['a.png', 'b.jpg', 'c.jpg']

	def test_instance(self):
		self.assertIsInstance(self.images, ImagesDownload, 'class ImagesDownload instantiation fail')

	def test_filePath(self):
		path = self.images.filePath()
		self.assertIsInstance(path, str, 'class ImagesDownload method filePath fail')

	def test_readFile(self):
		fileData = self.images.readFile(self.images.filePath()+'/tests/mock_test/mock_image_directory.txt')
		self.assertItemsEqual(fileData, self.mock_data,'class ImagesDownload method readFile fail')

	def tearDown(self):
		pass
def batch_downloader(file):
    """
    Takes a text file and scrapes the image URLs
    """
    images = ImagesDownload(fileName=file)
    dirName, imageBookPath = images.filePath()
    imageBookData = images.readFile(imageBookPath)
    images.downloadImages(dirName, imageBookData)
class TestImageDownloader(unittest.TestCase, ImagesDownload):
    def setUp(self):
        self.images = ImagesDownload(fileName=None)
        self.mock_data = ['a.png', 'b.jpg', 'c.jpg']

    def test_instance(self):
        self.assertIsInstance(self.images, ImagesDownload,
                              'class ImagesDownload instantiation fail')

    def test_filePath(self):
        path = self.images.filePath()
        self.assertIsInstance(path, str,
                              'class ImagesDownload method filePath fail')

    def test_readFile(self):
        fileData = self.images.readFile(
            self.images.filePath() +
            '/tests/mock_test/mock_image_directory.txt')
        self.assertItemsEqual(fileData, self.mock_data,
                              'class ImagesDownload method readFile fail')

    def tearDown(self):
        pass
	def setUp(self):
		self.images = ImagesDownload(fileName = None)
		self.mock_data = ['a.png', 'b.jpg', 'c.jpg']
 def setUp(self):
     self.images = ImagesDownload(fileName=None)
     self.mock_data = ['a.png', 'b.jpg', 'c.jpg']