def fc_networks(self): """ Gets the FcNetworks API client. Returns: FcNetworks: """ return FcNetworks(self.__connection)
def fc_networks(self): """ Gets the FcNetworks API client. Returns: FcNetworks: """ if not self.__fc_networks: self.__fc_networks = FcNetworks(self.__connection) return self.__fc_networks
def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host) self._fc_networks = FcNetworks(self.connection)
class FcNetworksTest(unittest.TestCase): def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host) self._fc_networks = FcNetworks(self.connection) @mock.patch.object(Resource, 'get_all') def test_get_all_called_once(self, mock_get_all): filter = 'name=TestName' sort = 'name:ascending' self._fc_networks.get_all(2, 500, filter, sort) mock_get_all.assert_called_once_with(2, 500, filter, sort) @mock.patch.object(Resource, 'create') def test_create_should_use_given_values(self, mock_create): resource = { 'name': 'OneViewSDK Test FC Network', 'autoLoginRedistribution': True, 'type': 'fc-networkV2', 'linkStabilityTime': 20, 'fabricType': None, } resource_rest_call = resource.copy() mock_create.return_value = {} self._fc_networks.create(resource, 30) mock_create.assert_called_once_with(resource_rest_call, 30) @mock.patch.object(Resource, 'update') def test_update_should_use_given_values(self, mock_update): resource = { 'name': 'OneViewSDK Test FC Network', 'autoLoginRedistribution': False, 'type': 'fc-networkV2', 'linkStabilityTime': 20, 'fabricType': None, 'uri': 'a_uri', } resource_rest_call = resource.copy() mock_update.return_value = {} self._fc_networks.update(resource, 60) mock_update.assert_called_once_with(resource_rest_call, 60) @mock.patch.object(Resource, 'delete') def test_delete_called_once(self, mock_delete): self._fc_networks.delete(force=False, timeout=-1) mock_delete.assert_called_once_with(force=False, timeout=-1) @mock.patch.object(Resource, 'get_by') def test_get_by_called_once(self, mock_get_by): self._fc_networks.get_by('name', 'OneViewSDK "Test FC Network') mock_get_by.assert_called_once_with('name', 'OneViewSDK "Test FC Network') @mock.patch.object(Resource, 'get_by_uri') def test_get_with_uri_called_once(self, mock_get): uri = '/rest/fc-networks/3518be0e-17c1-4189-8f81-83f3724f6155' self._fc_networks.get_by_uri(uri) mock_get.assert_called_once_with(uri) @mock.patch.object(ResourcePatchMixin, 'patch') def test_patch_should_use_user_defined_values(self, mock_patch): mock_patch.return_value = {} self._fc_networks.patch('/rest/fake/fc123', 'replace', '/scopeUris', ['/rest/fake/scope123'], 1) mock_patch.assert_called_once_with('/rest/fake/fc123', 'replace', '/scopeUris', ['/rest/fake/scope123'], 1)
class FcNetworksTest(unittest.TestCase): def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host) self._fc_networks = FcNetworks(self.connection) @mock.patch.object(ResourceClient, 'get_all') def test_get_all_called_once(self, mock_get_all): filter = 'name=TestName' sort = 'name:ascending' self._fc_networks.get_all(2, 500, filter, sort) mock_get_all.assert_called_once_with(2, 500, filter=filter, sort=sort) @mock.patch.object(ResourceClient, 'create') def test_create_should_use_given_values(self, mock_create): resource = { 'name': 'OneViewSDK Test FC Network', 'autoLoginRedistribution': True, 'type': 'fc-networkV2', 'linkStabilityTime': 20, 'fabricType': None, } resource_rest_call = resource.copy() mock_create.return_value = {} self._fc_networks.create(resource, 30) mock_create.assert_called_once_with( resource_rest_call, timeout=30, default_values=self._fc_networks.DEFAULT_VALUES) @mock.patch.object(ResourceClient, 'update') def test_update_should_use_given_values(self, mock_update): resource = { 'name': 'OneViewSDK Test FC Network', 'autoLoginRedistribution': False, 'type': 'fc-networkV2', 'linkStabilityTime': 20, 'fabricType': None, 'uri': 'a_uri', } resource_rest_call = resource.copy() mock_update.return_value = {} self._fc_networks.update(resource, 60) mock_update.assert_called_once_with( resource_rest_call, timeout=60, default_values=self._fc_networks.DEFAULT_VALUES) @mock.patch.object(ResourceClient, 'delete') def test_delete_called_once(self, mock_delete): id = 'ad28cf21-8b15-4f92-bdcf-51cb2042db32' self._fc_networks.delete(id, force=False, timeout=-1) mock_delete.assert_called_once_with(id, force=False, timeout=-1) @mock.patch.object(ResourceClient, 'get_by') def test_get_by_called_once(self, mock_get_by): self._fc_networks.get_by('name', 'OneViewSDK "Test FC Network') mock_get_by.assert_called_once_with('name', 'OneViewSDK "Test FC Network') @mock.patch.object(ResourceClient, 'get') def test_get_called_once(self, mock_get): self._fc_networks.get('3518be0e-17c1-4189-8f81-83f3724f6155') mock_get.assert_called_once_with( '3518be0e-17c1-4189-8f81-83f3724f6155') @mock.patch.object(ResourceClient, 'get') def test_get_with_uri_called_once(self, mock_get): uri = '/rest/fc-networks/3518be0e-17c1-4189-8f81-83f3724f6155' self._fc_networks.get(uri) mock_get.assert_called_once_with(uri)
def fc_networks(self): if not self.__fc_networks: self.__fc_networks = FcNetworks(self.__connection) return self.__fc_networks
class FcNetworksTest(unittest.TestCase): def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host) self._fc_networks = FcNetworks(self.connection) @mock.patch.object(ResourceClient, 'get_all') def test_get_all_called_once(self, mock_get_all): filter = 'name=TestName' sort = 'name:ascending' self._fc_networks.get_all(2, 500, filter, sort) mock_get_all.assert_called_once_with(2, 500, filter=filter, sort=sort) @mock.patch.object(ResourceClient, 'create') def test_create_should_use_given_values(self, mock_create): resource = { 'name': 'OneViewSDK Test FC Network', 'autoLoginRedistribution': True, 'type': 'fc-networkV2', 'linkStabilityTime': 20, 'fabricType': None, } resource_rest_call = resource.copy() mock_create.return_value = {} self._fc_networks.create(resource, 30) mock_create.assert_called_once_with(resource_rest_call, timeout=30, default_values=self._fc_networks.DEFAULT_VALUES) @mock.patch.object(ResourceClient, 'update') def test_update_should_use_given_values(self, mock_update): resource = { 'name': 'OneViewSDK Test FC Network', 'autoLoginRedistribution': False, 'type': 'fc-networkV2', 'linkStabilityTime': 20, 'fabricType': None, 'uri': 'a_uri', } resource_rest_call = resource.copy() mock_update.return_value = {} self._fc_networks.update(resource, 60) mock_update.assert_called_once_with(resource_rest_call, timeout=60, default_values=self._fc_networks.DEFAULT_VALUES) @mock.patch.object(ResourceClient, 'delete') def test_delete_called_once(self, mock_delete): id = 'ad28cf21-8b15-4f92-bdcf-51cb2042db32' self._fc_networks.delete(id, force=False, timeout=-1) mock_delete.assert_called_once_with(id, force=False, timeout=-1) @mock.patch.object(ResourceClient, 'get_by') def test_get_by_called_once(self, mock_get_by): self._fc_networks.get_by('name', 'OneViewSDK "Test FC Network') mock_get_by.assert_called_once_with('name', 'OneViewSDK "Test FC Network') @mock.patch.object(ResourceClient, 'get') def test_get_called_once(self, mock_get): self._fc_networks.get('3518be0e-17c1-4189-8f81-83f3724f6155') mock_get.assert_called_once_with('3518be0e-17c1-4189-8f81-83f3724f6155') @mock.patch.object(ResourceClient, 'get') def test_get_with_uri_called_once(self, mock_get): uri = '/rest/fc-networks/3518be0e-17c1-4189-8f81-83f3724f6155' self._fc_networks.get(uri) mock_get.assert_called_once_with(uri)