Beispiel #1
0
class FabricsTest(unittest.TestCase):
    def setUp(self):
        self.host = '127.0.0.1'
        self.connection = connection(self.host)
        self._fabrics = Fabrics(self.connection)

    @mock.patch.object(ResourceClient, 'get')
    def test_get_called_once(self, mock_get):
        self._fabrics.get('7a9f7d09-3c24-4efe-928f-50a1af411120')

        mock_get.assert_called_once_with(
            '7a9f7d09-3c24-4efe-928f-50a1af411120')

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

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

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

    @mock.patch.object(ResourceClient, 'get_by')
    def test_get_by_called_once(self, mock_get_by):
        self._fabrics.get_by('name', 'DefaultFabric')

        mock_get_by.assert_called_once_with('name', 'DefaultFabric')

    @mock.patch.object(ResourceClient, 'get')
    def test_get_reserved_vlan_range(self, mock_get):
        uri = '/rest/fabrics/123/reserved-vlan-range'
        self._fabrics.get_reserved_vlan_range('123')

        mock_get.assert_called_once_with(uri)

    @mock.patch.object(ResourceClient, 'update')
    def test_update_reserved_vlan_range(self, mock_update):
        uri = '/rest/fabrics/123/reserved-vlan-range'
        data_to_update = {
            "start": 100,
            "length": 100
        }

        self._fabrics.update_reserved_vlan_range('123', data_to_update)

        mock_update.assert_called_once_with(
            resource=data_to_update,
            uri=uri,
            force=False,
            default_values=Fabrics.DEFAULT_VALUES
        )
    def fabrics(self):
        """
        Gets the Fabrics API client.

        Returns:
            Fabrics:
        """
        if not self.__fabrics:
            self.__fabrics = Fabrics(self.__connection)
        return self.__fabrics
class FabricsTest(unittest.TestCase):

    def setUp(self):
        self.host = '127.0.0.1'
        self.connection = connection(self.host)
        self._fabrics = Fabrics(self.connection)

    @mock.patch.object(ResourceClient, 'get')
    def test_get_called_once(self, mock_get):
        self._fabrics.get('7a9f7d09-3c24-4efe-928f-50a1af411120')

        mock_get.assert_called_once_with(
            '7a9f7d09-3c24-4efe-928f-50a1af411120')

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

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

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

    @mock.patch.object(ResourceClient, 'get_by')
    def test_get_by_called_once(self, mock_get_by):
        self._fabrics.get_by('name', 'DefaultFabric')

        mock_get_by.assert_called_once_with(
            'name', 'DefaultFabric')
Beispiel #4
0
 def setUp(self):
     self.host = '127.0.0.1'
     self.connection = connection(self.host)
     self._fabrics = Fabrics(self.connection)
 def setUp(self):
     self.host = '127.0.0.1'
     self.connection = connection(self.host)
     self._fabrics = Fabrics(self.connection)
 def fabrics(self):
     if not self.__fabrics:
         self.__fabrics = Fabrics(self.__connection)
     return self.__fabrics