def id_pools_vmac_ranges(self): """ Gets the IdPoolsRanges API Client for VMAC Ranges. Returns: IdPoolsRanges: """ if not self.__id_pools_vmac_ranges: self.__id_pools_vmac_ranges = IdPoolsRanges('vmac', self.__connection) return self.__id_pools_vmac_ranges
def id_pools_vwwn_ranges(self): """ Gets the IdPoolsRanges API Client for VWWN Ranges. Returns: IdPoolsRanges: """ if not self.__id_pools_vwwn_ranges: self.__id_pools_vwwn_ranges = IdPoolsRanges('vwwn', self.__connection) return self.__id_pools_vwwn_ranges
def __init__(self, con): IdPoolsRanges.__init__(self, object, self.URI) self._connection = con self._client = ResourceClient(con, self.URI)
def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host) self.id_pool_name = 'vsn' self.client = IdPoolsRanges(self.id_pool_name, self.connection) self.example_uri = "/rest/id-pools/" + self.id_pool_name + "/ranges/f0a0a113-ec97-41b4-83ce-d7c92b900e7c"
class TestIdPoolsRanges(unittest.TestCase): resource_info = {'type': 'Range', 'name': 'No name'} def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host) self.id_pool_name = 'vsn' self.client = IdPoolsRanges(self.id_pool_name, self.connection) self.example_uri = "/rest/id-pools/" + self.id_pool_name + "/ranges/f0a0a113-ec97-41b4-83ce-d7c92b900e7c" @mock.patch.object(ResourceClient, '__init__') def test_id_pools_ranges_constructor_with_type_vsn(self, mock_rclient): mock_rclient.return_value = None IdPoolsRanges('vsn', self.connection) mock_rclient.assert_called_once_with(self.connection, '/rest/id-pools/vsn/ranges') @mock.patch.object(ResourceClient, '__init__') def test_id_pools_ranges_constructor_with_type_vwwn(self, mock_rclient): mock_rclient.return_value = None IdPoolsRanges('vwwn', self.connection) mock_rclient.assert_called_once_with(self.connection, '/rest/id-pools/vwwn/ranges') @mock.patch.object(ResourceClient, '__init__') def test_id_pools_ranges_constructor_with_type_vmac(self, mock_rclient): mock_rclient.return_value = None IdPoolsRanges('vmac', self.connection) mock_rclient.assert_called_once_with(self.connection, '/rest/id-pools/vmac/ranges') @mock.patch.object(ResourceClient, '__init__') def test_id_pools_ranges_constructor_with_invalid_type(self, mock_rclient): mock_rclient.return_value = None self.assertRaises(HPOneViewValueError, IdPoolsRanges, 'invalid', self.connection) @mock.patch.object(ResourceClient, 'create') def test_create_called_once(self, mock_create): self.client.create(self.resource_info) mock_create.assert_called_once_with(self.resource_info, timeout=-1) @mock.patch.object(ResourceClient, 'get') def test_get_by_id_called_once(self, mock_get): id_pools_range_id = "f0a0a113-ec97-41b4-83ce-d7c92b900e7c" self.client.get(id_pools_range_id) mock_get.assert_called_once_with(id_pools_range_id) @mock.patch.object(ResourceClient, 'get') def test_get_by_uri_called_once(self, mock_get): self.client.get(self.example_uri) mock_get.assert_called_once_with(self.example_uri) @mock.patch.object(ResourceClient, 'update') def test_enable_called_once(self, update): self.client.enable(self.resource_info.copy(), self.example_uri) update.assert_called_once_with(self.resource_info.copy(), self.example_uri, timeout=-1) @mock.patch.object(ResourceClient, 'get_collection') def test_get_allocated_fragments_called_once_with_defaults(self, mock_get): self.client.get_allocated_fragments(self.example_uri) mock_get.assert_called_once_with(self.example_uri + "/allocated-fragments?start=0&count=-1") @mock.patch.object(ResourceClient, 'get_collection') def test_get_allocated_fragments_called_once(self, mock_get): self.client.get_allocated_fragments(self.example_uri, 5, 2) mock_get.assert_called_once_with(self.example_uri + "/allocated-fragments?start=2&count=5") @mock.patch.object(ResourceClient, 'get_collection') def test_get_free_fragments_called_once_with_defaults(self, mock_get): self.client.get_free_fragments(self.example_uri) mock_get.assert_called_once_with(self.example_uri + "/free-fragments?start=0&count=-1") @mock.patch.object(ResourceClient, 'get_collection') def test_get_free_fragments_called_once(self, mock_get): self.client.get_free_fragments(self.example_uri, 5, 3) mock_get.assert_called_once_with(self.example_uri + "/free-fragments?start=3&count=5") @mock.patch.object(ResourceClient, 'delete') def test_delete_called_once(self, mock_delete): self.client.delete({'uri': '/rest/uri'}, force=True, timeout=50) mock_delete.assert_called_once_with({'uri': '/rest/uri'}, force=True, timeout=50) @mock.patch.object(ResourceClient, 'delete') def test_delete_called_once_with_defaults(self, mock_delete): self.client.delete({'uri': '/rest/uri'}) mock_delete.assert_called_once_with({'uri': '/rest/uri'}, force=False, timeout=-1) @mock.patch.object(ResourceClient, 'update') def test_allocate_called_once(self, mock_update): self.client.allocate(self.resource_info.copy(), self.example_uri) mock_update.assert_called_once_with(self.resource_info.copy(), self.example_uri + "/allocator", timeout=-1) @mock.patch.object(ResourceClient, 'update') def test_collect_called_once(self, update): self.client.collect(self.resource_info.copy(), self.example_uri) update.assert_called_once_with(self.resource_info.copy(), self.example_uri + "/collector", timeout=-1)
def test_id_pools_ranges_constructor_with_type_vmac(self, mock_rclient): mock_rclient.return_value = None IdPoolsRanges('vmac', self.connection) mock_rclient.assert_called_once_with(self.connection, '/rest/id-pools/vmac/ranges')
class TestIdPoolsRanges(unittest.TestCase): resource_info = {'type': 'Range', 'name': 'No name'} def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host) self.id_pool_name = 'vsn' self.client = IdPoolsRanges(self.id_pool_name, self.connection) self.example_uri = "/rest/id-pools/" + self.id_pool_name + "/ranges/f0a0a113-ec97-41b4-83ce-d7c92b900e7c" @mock.patch.object(ResourceClient, '__init__') def test_id_pools_ranges_constructor_with_type_vsn(self, mock_rclient): mock_rclient.return_value = None IdPoolsRanges('vsn', self.connection) mock_rclient.assert_called_once_with(self.connection, '/rest/id-pools/vsn/ranges') @mock.patch.object(ResourceClient, '__init__') def test_id_pools_ranges_constructor_with_type_vwwn(self, mock_rclient): mock_rclient.return_value = None IdPoolsRanges('vwwn', self.connection) mock_rclient.assert_called_once_with(self.connection, '/rest/id-pools/vwwn/ranges') @mock.patch.object(ResourceClient, '__init__') def test_id_pools_ranges_constructor_with_type_vmac(self, mock_rclient): mock_rclient.return_value = None IdPoolsRanges('vmac', self.connection) mock_rclient.assert_called_once_with(self.connection, '/rest/id-pools/vmac/ranges') @mock.patch.object(ResourceClient, '__init__') def test_id_pools_ranges_constructor_with_invalid_type(self, mock_rclient): mock_rclient.return_value = None self.assertRaises(HPOneViewValueError, IdPoolsRanges, 'invalid', self.connection) @mock.patch.object(ResourceClient, 'create') def test_create_called_once(self, mock_create): self.client.create(self.resource_info) mock_create.assert_called_once_with(self.resource_info, timeout=-1) @mock.patch.object(ResourceClient, 'get') def test_get_by_id_called_once(self, mock_get): id_pools_range_id = "f0a0a113-ec97-41b4-83ce-d7c92b900e7c" self.client.get(id_pools_range_id) mock_get.assert_called_once_with(id_pools_range_id) @mock.patch.object(ResourceClient, 'get') def test_get_by_uri_called_once(self, mock_get): self.client.get(self.example_uri) mock_get.assert_called_once_with(self.example_uri) @mock.patch.object(ResourceClient, 'update') def test_enable_called_once(self, update): self.client.enable(self.resource_info.copy(), self.example_uri) update.assert_called_once_with(self.resource_info.copy(), self.example_uri, timeout=-1) @mock.patch.object(ResourceClient, 'get_collection') def test_get_allocated_fragments_called_once_with_defaults(self, mock_get): self.client.get_allocated_fragments(self.example_uri) mock_get.assert_called_once_with( self.example_uri + "/allocated-fragments?start=0&count=-1") @mock.patch.object(ResourceClient, 'get_collection') def test_get_allocated_fragments_called_once(self, mock_get): self.client.get_allocated_fragments(self.example_uri, 5, 2) mock_get.assert_called_once_with( self.example_uri + "/allocated-fragments?start=2&count=5") @mock.patch.object(ResourceClient, 'get_collection') def test_get_free_fragments_called_once_with_defaults(self, mock_get): self.client.get_free_fragments(self.example_uri) mock_get.assert_called_once_with(self.example_uri + "/free-fragments?start=0&count=-1") @mock.patch.object(ResourceClient, 'get_collection') def test_get_free_fragments_called_once(self, mock_get): self.client.get_free_fragments(self.example_uri, 5, 3) mock_get.assert_called_once_with(self.example_uri + "/free-fragments?start=3&count=5") @mock.patch.object(ResourceClient, 'delete') def test_delete_called_once(self, mock_delete): self.client.delete({'uri': '/rest/uri'}, force=True, timeout=50) mock_delete.assert_called_once_with({'uri': '/rest/uri'}, force=True, timeout=50) @mock.patch.object(ResourceClient, 'delete') def test_delete_called_once_with_defaults(self, mock_delete): self.client.delete({'uri': '/rest/uri'}) mock_delete.assert_called_once_with({'uri': '/rest/uri'}, force=False, timeout=-1) @mock.patch.object(ResourceClient, 'update') def test_allocate_called_once(self, mock_update): self.client.allocate(self.resource_info.copy(), self.example_uri) mock_update.assert_called_once_with(self.resource_info.copy(), self.example_uri + "/allocator", timeout=-1) @mock.patch.object(ResourceClient, 'update') def test_collect_called_once(self, update): self.client.collect(self.resource_info.copy(), self.example_uri) update.assert_called_once_with(self.resource_info.copy(), self.example_uri + "/collector", timeout=-1)