def testImageExtract(self): """Testing for image extraction from given page""" #Initialize the extractor configFile = 'imageExtractionTest.yml' extractor = ScrapyExtractor(configFile, self.urlUtil) #Create an image item item = ImageArrayItem() item.init() #Create an HtmlResponse object for performing XPath operations on it bodyForResponse = self.urlUtil.getUrlResponse(self.urlAddress) response = HtmlResponse(self.urlAddress, body=bodyForResponse) #Extract images from the HtmlResponse object extractedData = extractor.extract(response, item) #Load the correct data and verify it with extracted trueData = json.load(open('correctImageData','r')) self.assertTrue(extractedData == trueData)
def testImageExtract(self): """Testing for image extraction from given page""" module_logger.debug('method testImageExtract was called') #Initialize the extractor configFile = os.path.dirname(__file__) + '/imageExtractionTest.yml' extractor = ScrapyExtractor(configFile, self.urlUtil) #Create an image item item = ImageArrayItem() item.init() #Create an HtmlResponse object for performing XPath operations on it bodyForResponse = self.urlUtil.getUrlResponse(self.urlAddress) response = HtmlResponse(self.urlAddress, body=bodyForResponse) #Extract images from the HtmlResponse object extractedData = extractor.extract(response, item) #Load the correct data and verify it with extracted trueData = json.load(open(os.path.dirname(__file__) + '/correctImageData','r')) self.assertTrue(extractedData == trueData) #print extractedData module_logger.debug('method testImageExtract completed successfully')