def test_findItem(self): '''Test out both local files and downloads with the findItem method''' # perform all of the the local file tests for thisTest in self.testMaterials: thisPackage = installerPackage(thisTest['fileName'], thisTest['checksumType'] + ":" + thisTest['checksumValue'], displayName=None) try: thisPackage.findItem(progressReporter=None) except FileNotFoundException, error: self.fail(thisTest['errorMessage'] + ', was unable to find a package - ' + str(error)) thisTest['resultPath'] = thisPackage.getItemLocalPath() self.assertEqual(thisTest['filePath'], thisPackage.getItemLocalPath(), thisTest['errorMessage'] + ', should have been "%(filePath)s" but was: "%(resultPath)s"' % thisTest)
def getDownloadedPkgInDmgPath(): global downloadedPkgInDmgPath if downloadedPkgInDmgPath is not None and os.path.exists(downloadedPkgInDmgPath): return downloadedPkgInDmgPath # download a smaller update from Apple if it is not already cached cacheController.setCacheFolder(tempFolderManager.tempFolderManager.getNewTempFolder()) cacheController.addSourceFolders(commonConfiguration.standardCacheFolder) sampleItemDMG = installerPackage.installerPackage('http://support.apple.com/downloads/DL792/en_US/AirPortClientUpdate2009001.dmg', 'sha1:168065c8bf2e6530a3053899ac7a6a210e9397d7') sampleItemDMG.findItem(progressReporter=False) downloadedPkgInDmgPath = sampleItemDMG.getItemLocalPath() return downloadedPkgInDmgPath
class findPackages(cacheControllerTest): def test_findItem(self): '''Test out both local files and downloads with the findItem method''' # perform all of the the local file tests for thisTest in self.testMaterials: thisPackage = installerPackage(thisTest['fileName'], thisTest['checksumType'] + ":" + thisTest['checksumValue'], displayName=None) try: thisPackage.findItem(progressReporter=None) except FileNotFoundException, error: self.fail(thisTest['errorMessage'] + ', was unable to find a package - ' + str(error)) thisTest['resultPath'] = thisPackage.getItemLocalPath() self.assertEqual( thisTest['filePath'], thisPackage.getItemLocalPath(), thisTest['errorMessage'] + ', should have been "%(filePath)s" but was: "%(resultPath)s"' % thisTest) # download a file thisPackage = installerPackage( 'http://images.apple.com/support/iknow/images/downloads_software_update.png', 'sha1:4d200d3fc229d929ea9ed64a9b5e06c5be733b38', displayName=None) try: thisPackage.findItem(progressReporter=None) self.assertEqual( os.path.join( cacheController.getCacheFolder(), 'downloads_software_update sha1-4d200d3fc229d929ea9ed64a9b5e06c5be733b38.png' ), thisPackage.getItemLocalPath(), "Downloading a file from Apple's site returned: " + str(thisPackage.getItemLocalPath())) except FileNotFoundException, error: self.fail(thisTest['errorMessage'] + ', was unable to find a package - ' + str(error))
def test_findItem(self): '''Test out both local files and downloads with the findItem method''' # perform all of the the local file tests for thisTest in self.testMaterials: thisPackage = installerPackage(thisTest['fileName'], thisTest['checksumType'] + ":" + thisTest['checksumValue'], displayName=None) try: thisPackage.findItem(progressReporter=None) except FileNotFoundException, error: self.fail(thisTest['errorMessage'] + ', was unable to find a package - ' + str(error)) thisTest['resultPath'] = thisPackage.getItemLocalPath() self.assertEqual( thisTest['filePath'], thisPackage.getItemLocalPath(), thisTest['errorMessage'] + ', should have been "%(filePath)s" but was: "%(resultPath)s"' % thisTest)