当前位置: 首页>>代码示例>>Python>>正文


Python ProfitBricksService.get_image方法代码示例

本文整理汇总了Python中profitbricks.client.ProfitBricksService.get_image方法的典型用法代码示例。如果您正苦于以下问题:Python ProfitBricksService.get_image方法的具体用法?Python ProfitBricksService.get_image怎么用?Python ProfitBricksService.get_image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在profitbricks.client.ProfitBricksService的用法示例。


在下文中一共展示了ProfitBricksService.get_image方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestImage

# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import get_image [as 别名]
class TestImage(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.resource = resource()
        self.client = ProfitBricksService(
            username=configuration.USERNAME,
            password=configuration.PASSWORD,
            headers=configuration.HEADERS)

        # Find an Ubuntu image for testing.
        for item in self.client.list_images()['items']:
            if 'Ubuntu-15' in item['properties']['name'] and item['properties']['location'] == configuration.LOCATION:
                self.image = item

    def test_list_images(self):
        images = self.client.list_images()

        self.assertGreater(len(images), 0)
        self.assertEqual(images['items'][0]['type'], 'image')
        assertRegex(self, images['items'][0]['id'], self.resource['uuid_match'])

    def test_get_image(self):
        image = self.client.get_image(self.image['id'])

        self.assertEqual(image['type'], 'image')
        self.assertEqual(image['id'], self.image['id'])
        self.assertIn(image['properties']['imageType'], ['HDD', 'CDROM'])
开发者ID:jbuchhammer,项目名称:profitbricks-sdk-python,代码行数:29,代码来源:test_image_live.py

示例2: TestImage

# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import get_image [as 别名]
class TestImage(unittest.TestCase):
    def setUp(self):
        self.image = ProfitBricksService(
            username='username', password='password')

    def test_list_images(self):
        images = self.image.list_images()

        self.assertEqual(len(images), 4)
        self.assertEqual(
            images['items'][0]['id'], '7df81087-5835-41c6-a10b-3e098593bbd2')

    def test_get_image(self):
        image_id = '7df81087-5835-41c6-a10b-3e098593bbd2'
        image = self.image.get_image(image_id)

        self.assertEqual(image['properties']['name'], 'Ubuntu 14.04')

    def test_delete_image(self):
        image_id = '7df81087-5835-41c6-a10b-3e098593bbd2'

        image = self.image.delete_image(image_id)
        self.assertTrue(image)

    def test_update_image(self):
        image_id = '7df81087-5835-41c6-a10b-3e098593bbd2'
        image = self.image.update_image(
            image_id,
            name='New name')

        self.assertEqual(image['properties']['name'], 'New name')
开发者ID:grandvizier,项目名称:profitbricks-sdk-python,代码行数:33,代码来源:test_image.py


注:本文中的profitbricks.client.ProfitBricksService.get_image方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。