本文整理汇总了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'])
示例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')