def testDownloadBadDir(self): """ Tests the file_utils.download() method when given a bad URL """ with self.assertRaises(Exception): file_utils.download( 'http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img', '/foo/bar')
def __download_image_file(self): """ Downloads the image file :return: the image file object """ if not file_utils.file_exists(self.image_file_path): logger.info('Downloading Image from - ' + self.image_url) return file_utils.download(self.image_url, self.download_path)
def testCirrosImageDownload(self): """ Tests the file_utils.download() method when given a good Cirros QCOW2 URL """ image_file = file_utils.download('http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img', self.tmpDir) self.assertIsNotNone(image_file) self.assertTrue(image_file.name.endswith("cirros-0.3.4-x86_64-disk.img")) self.assertTrue(image_file.name.startswith(self.tmpDir))
def testCirrosImageDownload(self): """ Tests the file_utils.download() method when given a good Cirros QCOW2 URL """ image_file = file_utils.download( 'http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img', self.tmpDir) self.assertIsNotNone(image_file) self.assertTrue( image_file.name.endswith("cirros-0.3.4-x86_64-disk.img")) self.assertTrue(image_file.name.startswith(self.tmpDir))
def testCreateImageWithExistingImageFile(self): """ Tests the creation of an OpenStack image when the image file exists. """ # Create download directory os.makedirs(os_image_settings.download_file_path) # Download image file file_utils.download(os_image_settings.url, os_image_settings.download_file_path) # Create Image created_image = self.os_image.create() glance = self.os_image.glance images = glance.images.list() # Validate for image in images: if image.name == self.os_image.image_name: self.assertEquals('active', image.status) self.assertEquals(created_image.id, image.id) return self.fail("Created image not found")
def testDownloadBadDir(self): """ Tests the file_utils.download() method when given a bad URL """ with self.assertRaises(Exception): file_utils.download('http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img', '/foo/bar')
def testDownloadBadUrl(self): """ Tests the file_utils.download() method when given a bad URL """ with self.assertRaises(Exception): file_utils.download('http://bunkUrl.com/foo/bar.iso', self.tmpDir)