class InternalLinkSetsTest(TestCase):
    def setUp(self):
        self.host = '127.0.0.1'
        self.connection = connection(self.host)
        self._client = InternalLinkSets(self.connection)

    @mock.patch.object(ResourceClient, 'get_all')
    def test_get_all_called_once(self, mock_get_all):
        filter = 'name=TestName'
        sort = 'name:ascending'
        query = 'teste'
        fields = 'a,b,c'
        view = 'teste'

        self._client.get_all(2, 500, filter, query, sort, view, fields)

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

    @mock.patch.object(ResourceClient, 'get_all')
    def test_get_all_without_parameters(self, mock_get_all):
        self._client.get_all()
        mock_get_all.assert_called_once_with(start=0, count=-1, filter='', sort='', query='', fields='', view='')

    @mock.patch.object(ResourceClient, 'get_all')
    def test_get_by_called_once(self, mock_get_all):
        mock_get_all.return_value = INTERNAL_LINK_SETS
        expected_result = [
            {'name': 'OneViewSDK Test Internal Link Set'},
            {'name': 'OneViewSDK Test Internal Link Set'},
        ]

        result = self._client.get_by('name', 'OneViewSDK Test Internal Link Set')

        self.assertEqual(result, expected_result)

    @mock.patch.object(ResourceClient, 'get_all')
    def test_get_by_should_return_empty_list_when_not_match(self, mock_get_all):
        mock_get_all.return_value = INTERNAL_LINK_SETS
        expected_result = []

        result = self._client.get_by('name', 'Testing')

        self.assertEqual(result, expected_result)

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

        mock_get.assert_called_once_with(uri)
    def internal_link_sets(self):
        """
        Gets the InternalLinkSets API client.

        Returns:
            InternalLinkSets:
        """
        return InternalLinkSets(self.__connection)
    def internal_link_sets(self):
        """
        Gets the InternalLinkSets API client.

        Returns:
            InternalLinkSets:
        """
        if not self.__internal_link_sets:
            self.__internal_link_sets = InternalLinkSets(self.__connection)
        return self.__internal_link_sets
 def setUp(self):
     self.host = '127.0.0.1'
     self.connection = connection(self.host)
     self._client = InternalLinkSets(self.connection)
class InternalLinkSetsTest(TestCase):
    def setUp(self):
        self.host = '127.0.0.1'
        self.connection = connection(self.host)
        self._client = InternalLinkSets(self.connection)

    @mock.patch.object(ResourceHelper, 'get_all')
    def test_get_all_called_once(self, mock_get_all):
        filter = 'name=TestName'
        sort = 'name:ascending'
        query = 'teste'
        fields = 'a,b,c'
        view = 'teste'

        self._client.get_all(2, 500, filter, query, sort, view, fields)

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

    @mock.patch.object(ResourceHelper, 'get_all')
    def test_get_all_without_parameters(self, mock_get_all):
        self._client.get_all()
        mock_get_all.assert_called_once_with(start=0,
                                             count=-1,
                                             filter='',
                                             sort='',
                                             query='',
                                             fields='',
                                             view='')

    @mock.patch.object(ResourceHelper, 'get_all')
    def test_get_by_called_once(self, mock_get_all):
        mock_get_all.return_value = INTERNAL_LINK_SETS
        expected_result = [
            {
                'name': 'OneViewSDK Test Internal Link Set'
            },
            {
                'name': 'OneViewSDK Test Internal Link Set'
            },
        ]

        result = self._client.get_by('name',
                                     'OneViewSDK Test Internal Link Set')

        self.assertEqual(result, expected_result)

    @mock.patch.object(ResourceHelper, 'get_all')
    def test_get_by_should_return_empty_list_when_not_match(
            self, mock_get_all):
        mock_get_all.return_value = INTERNAL_LINK_SETS
        expected_result = []

        result = self._client.get_by('name', 'Testing')

        self.assertEqual(result, expected_result)
 def setUp(self):
     self.host = '127.0.0.1'
     self.connection = connection(self.host)
     self._client = InternalLinkSets(self.connection)