當前位置: 首頁>>代碼示例>>Python>>正文


Python ProfitBricksService.get_ipblock方法代碼示例

本文整理匯總了Python中profitbricks.client.ProfitBricksService.get_ipblock方法的典型用法代碼示例。如果您正苦於以下問題:Python ProfitBricksService.get_ipblock方法的具體用法?Python ProfitBricksService.get_ipblock怎麽用?Python ProfitBricksService.get_ipblock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在profitbricks.client.ProfitBricksService的用法示例。


在下文中一共展示了ProfitBricksService.get_ipblock方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestIPBlock

# 需要導入模塊: from profitbricks.client import ProfitBricksService [as 別名]
# 或者: from profitbricks.client.ProfitBricksService import get_ipblock [as 別名]
class TestIPBlock(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.resource = resource()
        self.client = ProfitBricksService(
            username=configuration.USERNAME,
            password=configuration.PASSWORD,
            headers=configuration.HEADERS)

        ipblock1 = IPBlock(**self.resource['ipblock'])
        self.ipblock1 = self.client.reserve_ipblock(ipblock1)

        ipblock2 = IPBlock(**self.resource['ipblock'])
        self.ipblock2 = self.client.reserve_ipblock(ipblock2)

    @classmethod
    def tearDownClass(self):
        self.client.delete_ipblock(self.ipblock1['id'])

    def test_list_ipblocks(self):
        ipblocks = self.client.list_ipblocks()

        assertRegex(self, ipblocks['items'][0]['id'], self.resource['uuid_match'])
        self.assertGreater(len(ipblocks), 0)
        assertRegex(self, ipblocks['items'][0]['id'], self.resource['uuid_match'])
        self.assertGreater(ipblocks['items'][0]['properties']['size'], 0)
        self.assertIn(ipblocks['items'][0]['properties']['location'], self.resource['locations'])

    def test_get_ipblock(self):
        ipblock = self.client.get_ipblock(self.ipblock1['id'])

        assertRegex(self, ipblock['id'], self.resource['uuid_match'])
        self.assertEqual(ipblock['id'], self.ipblock1['id'])
        self.assertEqual(ipblock['properties']['name'], (self.resource['ipblock']['name']))
        self.assertEqual(ipblock['properties']['size'], self.resource['ipblock']['size'])
        self.assertEqual(ipblock['properties']['location'], self.resource['ipblock']['location'])

    def test_delete_ipblock(self):
        ipblock = self.client.delete_ipblock(self.ipblock2['id'])

        self.assertTrue(ipblock)

    def test_reserve_ipblock(self):
        ipblock = self.client.reserve_ipblock(IPBlock(**self.resource['ipblock']))

        assertRegex(self, ipblock['id'], self.resource['uuid_match'])
        self.assertEqual(ipblock['properties']['name'], (self.resource['ipblock']['name']))
        self.assertEqual(ipblock['properties']['size'], self.resource['ipblock']['size'])
        self.assertEqual(ipblock['properties']['location'], self.resource['ipblock']['location'])

        self.client.delete_ipblock(ipblock['id'])
開發者ID:fbrehm,項目名稱:profitbricks-sdk-python,代碼行數:53,代碼來源:test_ipblock_live.py

示例2: TestIPBlock

# 需要導入模塊: from profitbricks.client import ProfitBricksService [as 別名]
# 或者: from profitbricks.client.ProfitBricksService import get_ipblock [as 別名]
class TestIPBlock(unittest.TestCase):
    def setUp(self):
        self.ipblock = ProfitBricksService(
            username='username', password='password')

    def test_list_ipblocks(self):
        ipblocks = self.ipblock.list_ipblocks()

        self.assertEqual(len(ipblocks), 4)
        self.assertEqual(ipblocks['items'][0]['id'], ipblock_id)
        self.assertEqual(
            ipblocks['items'][0]['properties']['size'], 5)
        self.assertEqual(
            ipblocks['items'][0]['properties']['location'], 'de/fra')

    def test_get_ipblock(self):
        ipblock = self.ipblock.get_ipblock(ipblock_id)

        self.assertEqual(ipblock['id'], ipblock_id)
        self.assertEqual(ipblock['properties']['size'], 5)
        self.assertEqual(
            ipblock['properties']['location'], 'de/fra')

    def test_delete_ipblock(self):
        ipblock = self.ipblock.delete_ipblock(ipblock_id)
        self.assertTrue(ipblock)

    def test_reserve_ipblock(self):
        i = IPBlock(location='de/fra', size=5)

        ipblock = self.ipblock.reserve_ipblock(i)

        self.assertEqual(ipblock['id'], ipblock_id)
        self.assertEqual(ipblock['properties']['size'], 5)
        self.assertEqual(
            ipblock['properties']['location'], 'de/fra')
開發者ID:grandvizier,項目名稱:profitbricks-sdk-python,代碼行數:38,代碼來源:test_ipblock.py


注:本文中的profitbricks.client.ProfitBricksService.get_ipblock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。