def fcoe_networks(self):
        """
        Gets the FcoeNetworks API client.

        Returns:
            FcoeNetworks:
        """
        return FcoeNetworks(self.__connection)
    def fcoe_networks(self):
        """
        Gets the FcoeNetworks API client.

        Returns:
            FcoeNetworks:
        """
        if not self.__fcoe_networks:
            self.__fcoe_networks = FcoeNetworks(self.__connection)
        return self.__fcoe_networks
Beispiel #3
0
 def setUp(self):
     self.host = '127.0.0.1'
     self.connection = connection(self.host)
     self._fcoe_networks = FcoeNetworks(self.connection)
     self.uri = "/rest/fcoe-networks/3518be0e-17c1-4189-8f81-83f3724f6155"
     self._fcoe_networks.data = {"uri": self.uri}
Beispiel #4
0
class FcoeNetworksTest(TestCase):
    def setUp(self):
        self.host = '127.0.0.1'
        self.connection = connection(self.host)
        self._fcoe_networks = FcoeNetworks(self.connection)
        self.uri = "/rest/fcoe-networks/3518be0e-17c1-4189-8f81-83f3724f6155"
        self._fcoe_networks.data = {"uri": self.uri}

    @mock.patch.object(ResourceHelper, 'get_all')
    def test_get_all_called_once(self, mock_get_all):
        filter = 'name=TestName'
        sort = 'name:ascending'

        self._fcoe_networks.get_all(2, 500, filter, sort)

        mock_get_all.assert_called_once_with(start=2,
                                             count=500,
                                             filter=filter,
                                             sort=sort)

    @mock.patch.object(ResourceHelper, 'create')
    def test_create(self, mock_create):
        resource = {
            'name': 'OneViewSDK Test FCoE Network',
        }

        mock_create.return_value = {}

        self._fcoe_networks.create(resource)

        mock_create.assert_called_once_with(resource, None, -1, None, False)

    @mock.patch.object(Resource, 'ensure_resource_data')
    @mock.patch.object(ResourceHelper, 'update')
    def test_update(self, mock_update, mock_ensure_client):
        resource = {
            'name': 'vsan1',
            'vlanId': '201',
            'connectionTemplateUri': None,
            'type': 'fcoe-networkV2',
        }
        resource_rest_call = resource.copy()
        resource_rest_call.update(self._fcoe_networks.data)
        mock_update.return_value = {}

        self._fcoe_networks.update(resource, timeout=12)
        mock_update.assert_called_once_with(resource_rest_call, self.uri,
                                            False, 12, None)

    @mock.patch.object(ResourceHelper, 'delete')
    def test_delete_called_once(self, mock_delete):
        self._fcoe_networks.delete(force=False, timeout=50)

        mock_delete.assert_called_once_with(self.uri,
                                            force=False,
                                            custom_headers=None,
                                            timeout=50)

    @mock.patch.object(Resource, 'get_by')
    def test_get_by_called_once(self, mock_get_by):
        self._fcoe_networks.get_by('name', 'OneViewSDK Test FCoE Network')

        mock_get_by.assert_called_once_with('name',
                                            'OneViewSDK Test FCoE Network')

    @mock.patch.object(ResourcePatchMixin, 'patch_request')
    def test_patch_should_use_user_defined_values(self, mock_patch_request):
        mock_patch_request.return_value = {}

        self._fcoe_networks.patch('replace',
                                  '/scopeUris', ['/rest/fake/scope123'],
                                  timeout=-1)
        mock_patch_request.assert_called_once_with(self.uri,
                                                   body=[{
                                                       'path':
                                                       '/scopeUris',
                                                       'value':
                                                       ['/rest/fake/scope123'],
                                                       'op':
                                                       'replace'
                                                   }],
                                                   custom_headers=None,
                                                   timeout=-1)
class FcoeNetworksTest(TestCase):
    def setUp(self):
        self.host = '127.0.0.1'
        self.connection = connection(self.host)
        self._fcoe_networks = FcoeNetworks(self.connection)
        self.uri = "/rest/fcoe-networks/3518be0e-17c1-4189-8f81-83f3724f6155"
        self._fcoe_networks.data = {"uri": self.uri}

    @mock.patch.object(ResourceHelper, 'get_all')
    def test_get_all_called_once(self, mock_get_all):
        filter = 'name=TestName'
        sort = 'name:ascending'

        self._fcoe_networks.get_all(2, 500, filter, sort)

        mock_get_all.assert_called_once_with(start=2, count=500, filter=filter, sort=sort)

    @mock.patch.object(ResourceHelper, 'create')
    def test_create(self, mock_create):
        resource = {
            'name': 'OneViewSDK Test FCoE Network',
        }

        mock_create.return_value = {}

        self._fcoe_networks.create(resource)

        mock_create.assert_called_once_with(resource, None, -1, None, False)

    @mock.patch.object(Resource, 'ensure_resource_data')
    @mock.patch.object(ResourceHelper, 'update')
    def test_update(self, mock_update, mock_ensure_client):
        resource = {
            'name': 'vsan1',
            'vlanId': '201',
            'connectionTemplateUri': None,
            'type': 'fcoe-networkV2',
        }
        resource_rest_call = resource.copy()
        resource_rest_call.update(self._fcoe_networks.data)
        mock_update.return_value = {}

        self._fcoe_networks.update(resource, timeout=12)
        mock_update.assert_called_once_with(resource_rest_call, self.uri, False, 12, None)

    @mock.patch.object(ResourceHelper, 'delete')
    def test_delete_called_once(self, mock_delete):
        self._fcoe_networks.delete(force=False, timeout=50)

        mock_delete.assert_called_once_with(self.uri, force=False,
                                            custom_headers=None, timeout=50)

    @mock.patch.object(Resource, 'get_by')
    def test_get_by_called_once(self, mock_get_by):
        self._fcoe_networks.get_by('name', 'OneViewSDK Test FCoE Network')

        mock_get_by.assert_called_once_with('name', 'OneViewSDK Test FCoE Network')

    @mock.patch.object(ResourcePatchMixin, 'patch_request')
    def test_patch_should_use_user_defined_values(self, mock_patch_request):
        mock_patch_request.return_value = {}

        self._fcoe_networks.patch('replace', '/scopeUris', ['/rest/fake/scope123'], timeout=-1)
        mock_patch_request.assert_called_once_with(self.uri,
                                                   body=[{'path': '/scopeUris',
                                                          'value': ['/rest/fake/scope123'],
                                                          'op': 'replace'}],
                                                   custom_headers=None,
                                                   timeout=-1)
 def setUp(self):
     self.host = '127.0.0.1'
     self.connection = connection(self.host)
     self._fcoe_networks = FcoeNetworks(self.connection)
     self.uri = "/rest/fcoe-networks/3518be0e-17c1-4189-8f81-83f3724f6155"
     self._fcoe_networks.data = {"uri": self.uri}
 def fcoe_networks(self):
     if not self.__fcoe_networks:
         self.__fcoe_networks = FcoeNetworks(self.__connection)
     return self.__fcoe_networks
Beispiel #8
0
 def setUp(self):
     self.host = '127.0.0.1'
     self.connection = connection(self.host)
     self._fcoe_networks = FcoeNetworks(self.connection)
Beispiel #9
0
class FcoeNetworksTest(TestCase):
    def setUp(self):
        self.host = '127.0.0.1'
        self.connection = connection(self.host)
        self._fcoe_networks = FcoeNetworks(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._fcoe_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(self, mock_create):
        resource = {
            'name': 'OneViewSDK Test FCoE Network',
        }

        mock_create.return_value = {}

        self._fcoe_networks.create(resource)

        mock_create.assert_called_once_with(
            resource,
            timeout=-1,
            default_values=self._fcoe_networks.DEFAULT_VALUES)

    @mock.patch.object(ResourceClient, 'update')
    def test_update(self, mock_update):
        resource = {
            'name': 'vsan1',
            'vlanId': '201',
            'connectionTemplateUri': None,
            'type': 'fcoe-networkV2',
        }
        resource_rest_call = resource.copy()
        mock_update.return_value = {}

        self._fcoe_networks.update(resource, timeout=12)
        mock_update.assert_called_once_with(
            resource_rest_call,
            timeout=12,
            default_values=self._fcoe_networks.DEFAULT_VALUES)

    @mock.patch.object(ResourceClient, 'delete')
    def test_delete_called_once(self, mock_delete):
        id = 'ad28cf21-8b15-4f92-bdcf-51cb2042db32'
        self._fcoe_networks.delete(id, force=False, timeout=50)

        mock_delete.assert_called_once_with(id, force=False, timeout=50)

    @mock.patch.object(ResourceClient, 'get_by')
    def test_get_by_called_once(self, mock_get_by):
        self._fcoe_networks.get_by('name', 'OneViewSDK Test FCoE Network')

        mock_get_by.assert_called_once_with('name',
                                            'OneViewSDK Test FCoE Network')

    @mock.patch.object(ResourceClient, 'get')
    def test_get_called_once(self, mock_get):
        self._fcoe_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/fcoe-networks/3518be0e-17c1-4189-8f81-83f3724f6155'
        self._fcoe_networks.get(uri)

        mock_get.assert_called_once_with(uri)

    @mock.patch.object(ResourceClient, 'patch')
    def test_patch_should_use_user_defined_values(self, mock_patch):
        mock_patch.return_value = {}

        self._fcoe_networks.patch('/rest/fake/fcoe123', 'replace',
                                  '/scopeUris', ['/rest/fake/scope123'], 1)
        mock_patch.assert_called_once_with('/rest/fake/fcoe123',
                                           'replace',
                                           '/scopeUris',
                                           ['/rest/fake/scope123'],
                                           timeout=1)
 def setUp(self):
     self.host = '127.0.0.1'
     self.connection = connection(self.host)
     self._fcoe_networks = FcoeNetworks(self.connection)
class FcoeNetworksTest(TestCase):
    def setUp(self):
        self.host = '127.0.0.1'
        self.connection = connection(self.host)
        self._fcoe_networks = FcoeNetworks(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._fcoe_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': 'vsan1',
            'vlanId': '201',
            'connectionTemplateUri': None,
            'type': 'fcoe-networkV2',
        }
        resource_rest_call = resource.copy()
        mock_create.return_value = {}

        self._fcoe_networks.create(resource, 10)
        mock_create.assert_called_once_with(resource_rest_call, timeout=10)

    @mock.patch.object(ResourceClient, 'create')
    def test_create_should_use_default_values(self, mock_create):
        resource = {
            'name': 'OneViewSDK Test FCoE Network',
        }
        resource_with_default_values = {
            'name': 'OneViewSDK Test FCoE Network',
            'type': 'fcoe-network',
        }
        mock_create.return_value = {}

        self._fcoe_networks.create(resource)

        mock_create.assert_called_once_with(resource_with_default_values, timeout=-1)

    @mock.patch.object(ResourceClient, 'update')
    def test_update_should_use_given_values(self, mock_update):
        resource = {
            'name': 'vsan1',
            'vlanId': '201',
            'connectionTemplateUri': None,
            'type': 'fcoe-networkV2',
        }
        resource_rest_call = resource.copy()
        mock_update.return_value = {}

        self._fcoe_networks.update(resource, timeout=12)
        mock_update.assert_called_once_with(resource_rest_call, timeout=12)

    @mock.patch.object(ResourceClient, 'update')
    def test_update_should_use_default_values(self, mock_update):
        resource = {
            'name': 'OneViewSDK Test FCoE Network',
        }
        resource_with_default_values = {
            'name': 'OneViewSDK Test FCoE Network',
            'type': 'fcoe-network',
        }
        mock_update.return_value = {}

        self._fcoe_networks.update(resource)

        mock_update.assert_called_once_with(resource_with_default_values, timeout=-1)

    @mock.patch.object(ResourceClient, 'delete')
    def test_delete_called_once(self, mock_delete):
        id = 'ad28cf21-8b15-4f92-bdcf-51cb2042db32'
        self._fcoe_networks.delete(id, force=False, timeout=50)

        mock_delete.assert_called_once_with(id, force=False, timeout=50)

    @mock.patch.object(ResourceClient, 'get_by')
    def test_get_by_called_once(self, mock_get_by):
        self._fcoe_networks.get_by('name', 'OneViewSDK Test FCoE Network')

        mock_get_by.assert_called_once_with('name', 'OneViewSDK Test FCoE Network')

    @mock.patch.object(ResourceClient, 'get')
    def test_get_called_once(self, mock_get):
        self._fcoe_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/fcoe-networks/3518be0e-17c1-4189-8f81-83f3724f6155'
        self._fcoe_networks.get(uri)

        mock_get.assert_called_once_with(uri)