def enclosure_groups(self):
        """
        Gets the EnclosureGroups API client.

        Returns:
            EnclosureGroups:
        """
        return EnclosureGroups(self.__connection)
    def enclosure_groups(self):
        """
        Gets the EnclosureGroups API client.

        Returns:
            EnclosureGroups:
        """
        if not self.__enclosure_groups:
            self.__enclosure_groups = EnclosureGroups(self.__connection)
        return self.__enclosure_groups
Beispiel #3
0
 def setUp(self):
     self.host = '127.0.0.1'
     self.connection = connection(self.host)
     self.client = EnclosureGroups(self.connection)
Beispiel #4
0
class EnclosureGroupsTest(unittest.TestCase):
    MINIMAL_DATA_FOR_EG_CREATION = {
        "name":
        "Enclosure Group 1",
        "stackingMode":
        "Enclosure",
        "interconnectBayMappings": [{
            "interconnectBay": 1,
        }, {
            "interconnectBay": 2,
        }, {
            "interconnectBay": 3,
        }, {
            "interconnectBay": 4,
        }, {
            "interconnectBay": 5,
        }, {
            "interconnectBay": 6,
        }, {
            "interconnectBay": 7,
        }, {
            "interconnectBay": 8,
        }]
    }

    def setUp(self):
        self.host = '127.0.0.1'
        self.connection = connection(self.host)
        self.client = EnclosureGroups(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.client.get_all(2, 500, filter, sort)

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

    @mock.patch.object(ResourceClient, 'get_all')
    def test_get_all_called_once_with_default(self, mock_get_all):
        self.client.get_all()
        mock_get_all.assert_called_once_with(0, -1, filter='', sort='')

    @mock.patch.object(ResourceClient, 'get')
    def test_get_by_id_called_once(self, mock_get):
        id = "f0a0a113-ec97-41b4-83ce-d7c92b900e7c"
        self.client.get(id)
        mock_get.assert_called_once_with(id)

    @mock.patch.object(ResourceClient, 'get')
    def test_get_by_uri_called_once(self, mock_get):
        uri = "/rest/enclosure-groups/f0a0a113-ec97-41b4-83ce-d7c92b900e7c"
        self.client.get(uri)
        mock_get.assert_called_once_with(uri)

    @mock.patch.object(ResourceClient, 'get')
    def test_get_script_by_id_called_once(self, mock_get):
        id = "f0a0a113-ec97-41b4-83ce-d7c92b900e7c"
        self.client.get_script(id)
        mock_get.assert_called_once_with(
            "/rest/enclosure-groups/f0a0a113-ec97-41b4-83ce-d7c92b900e7c/script"
        )

    @mock.patch.object(ResourceClient, 'get')
    def test_get_script_by_uri_called_once(self, mock_get):
        uri = "/rest/enclosure-groups/f0a0a113-ec97-41b4-83ce-d7c92b900e7c"
        self.client.get_script(uri)
        mock_get.assert_called_once_with(uri + "/script")

    @mock.patch.object(ResourceClient, 'get_by')
    def test_get_by_called_once(self, mock_get_by):
        self.client.get_by("name", "test name")
        mock_get_by.assert_called_once_with("name", "test name")

    @mock.patch.object(ResourceClient, 'create')
    def test_create_called_once(self, mock_create):
        eg_initial = self.MINIMAL_DATA_FOR_EG_CREATION.copy()

        self.client.create(eg_initial)

        eg_expected = self.MINIMAL_DATA_FOR_EG_CREATION.copy()

        mock_create.assert_called_once_with(
            eg_expected, timeout=-1, default_values=self.client.DEFAULT_VALUES)

    @mock.patch.object(ResourceClient, 'delete')
    def test_delete_called_once(self, mock_delete):
        self.client.delete({"an_entity": ""})

        mock_delete.assert_called_once_with({"an_entity": ""}, timeout=-1)

    @mock.patch.object(ResourceClient, 'update')
    def test_update_called_once(self, mock_update):
        eg_initial = self.MINIMAL_DATA_FOR_EG_CREATION.copy()

        self.client.update(eg_initial)

        eg_expected = self.MINIMAL_DATA_FOR_EG_CREATION.copy()

        mock_update.assert_called_once_with(
            eg_expected, timeout=-1, default_values=self.client.DEFAULT_VALUES)

    @mock.patch.object(ResourceClient, 'update')
    def test_update_script_by_uri_called_once(self, mock_update):
        uri = "/rest/enclosure-groups/f0a0a113-ec97-41b4-83ce-d7c92b900e7c"
        script_body = "#TEST COMMAND"
        self.client.update_script(uri, script_body)
        mock_update.assert_called_once_with(script_body, uri=uri + "/script")
 def setUp(self):
     self.host = '127.0.0.1'
     self.connection = connection(self.host)
     self.client = EnclosureGroups(self.connection)
class EnclosureGroupsTest(unittest.TestCase):
    MINIMAL_DATA_FOR_EG_CREATION = {
        "name": "Enclosure Group 1",
        "stackingMode": "Enclosure",
        "interconnectBayMappings":
            [
                {
                    "interconnectBay": 1,
                },
                {
                    "interconnectBay": 2,
                },
                {
                    "interconnectBay": 3,
                },
                {
                    "interconnectBay": 4,
                },
                {
                    "interconnectBay": 5,
                },
                {
                    "interconnectBay": 6,
                },
                {
                    "interconnectBay": 7,
                },
                {
                    "interconnectBay": 8,
                }
            ]
    }

    def setUp(self):
        self.host = '127.0.0.1'
        self.connection = connection(self.host)
        self.client = EnclosureGroups(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.client.get_all(2, 500, filter, sort)

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

    @mock.patch.object(ResourceClient, 'get_all')
    def test_get_all_called_once_with_default(self, mock_get_all):
        self.client.get_all()
        mock_get_all.assert_called_once_with(0, -1, filter='', sort='')

    @mock.patch.object(ResourceClient, 'get')
    def test_get_by_id_called_once(self, mock_get):
        id = "f0a0a113-ec97-41b4-83ce-d7c92b900e7c"
        self.client.get(id)
        mock_get.assert_called_once_with(id)

    @mock.patch.object(ResourceClient, 'get')
    def test_get_by_uri_called_once(self, mock_get):
        uri = "/rest/enclosure-groups/f0a0a113-ec97-41b4-83ce-d7c92b900e7c"
        self.client.get(uri)
        mock_get.assert_called_once_with(uri)

    @mock.patch.object(ResourceClient, 'get')
    def test_get_script_by_id_called_once(self, mock_get):
        id = "f0a0a113-ec97-41b4-83ce-d7c92b900e7c"
        self.client.get_script(id)
        mock_get.assert_called_once_with("/rest/enclosure-groups/f0a0a113-ec97-41b4-83ce-d7c92b900e7c/script")

    @mock.patch.object(ResourceClient, 'get')
    def test_get_script_by_uri_called_once(self, mock_get):
        uri = "/rest/enclosure-groups/f0a0a113-ec97-41b4-83ce-d7c92b900e7c"
        self.client.get_script(uri)
        mock_get.assert_called_once_with(uri + "/script")

    @mock.patch.object(ResourceClient, 'get_by')
    def test_get_by_called_once(self, mock_get_by):
        self.client.get_by("name", "test name")
        mock_get_by.assert_called_once_with("name", "test name")

    @mock.patch.object(ResourceClient, 'create')
    def test_create_called_once(self, mock_create):
        eg_initial = self.MINIMAL_DATA_FOR_EG_CREATION.copy()

        self.client.create(eg_initial)

        eg_expected = self.MINIMAL_DATA_FOR_EG_CREATION.copy()
        eg_expected["type"] = "EnclosureGroupV200"

        mock_create.assert_called_once_with(eg_expected, timeout=-1)

    @mock.patch.object(ResourceClient, 'delete')
    def test_delete_called_once(self, mock_delete):
        self.client.delete({"an_entity": ""})

        mock_delete.assert_called_once_with({"an_entity": ""}, timeout=-1)

    @mock.patch.object(ResourceClient, 'update')
    def test_update_called_once(self, mock_update):
        eg_initial = self.MINIMAL_DATA_FOR_EG_CREATION.copy()

        self.client.update(eg_initial)

        eg_expected = self.MINIMAL_DATA_FOR_EG_CREATION.copy()
        eg_expected["type"] = "EnclosureGroupV200"

        mock_update.assert_called_once_with(eg_expected, timeout=-1)

    @mock.patch.object(ResourceClient, 'update')
    def test_update_script_by_uri_called_once(self, mock_update):
        uri = "/rest/enclosure-groups/f0a0a113-ec97-41b4-83ce-d7c92b900e7c"
        script_body = "#TEST COMMAND"
        self.client.update_script(uri, script_body)
        mock_update.assert_called_once_with(script_body, uri=uri + "/script")
 def enclosure_groups(self):
     if not self.__enclosure_groups:
         self.__enclosure_groups = EnclosureGroups(self.__connection)
     return self.__enclosure_groups
 def setUp(self):
     self.host = '127.0.0.1'
     self.connection = connection(self.host)
     self.client = EnclosureGroups(self.connection)
     self.uri = "/rest/enclosure-groups/f0a0a113-ec97-41b4-83ce-d7c92b900e7c"
     self.client.data = {"uri": self.uri}
class EnclosureGroupsTest(unittest.TestCase):
    MINIMAL_DATA_FOR_EG_CREATION = {
        "name": "Enclosure Group 1",
        "stackingMode": "Enclosure",
        "interconnectBayMappings":
            [
                {
                    "interconnectBay": 1,
                },
                {
                    "interconnectBay": 2,
                },
                {
                    "interconnectBay": 3,
                },
                {
                    "interconnectBay": 4,
                },
                {
                    "interconnectBay": 5,
                },
                {
                    "interconnectBay": 6,
                },
                {
                    "interconnectBay": 7,
                },
                {
                    "interconnectBay": 8,
                }
            ]
    }

    def setUp(self):
        self.host = '127.0.0.1'
        self.connection = connection(self.host)
        self.client = EnclosureGroups(self.connection)
        self.uri = "/rest/enclosure-groups/f0a0a113-ec97-41b4-83ce-d7c92b900e7c"
        self.client.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'
        scope_uris = 'rest/scopes/cd237b60-09e2-45c4-829e-082e318a6d2a'
        self.client.get_all(2, 500, filter, sort, scope_uris)

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

    @mock.patch.object(ResourceHelper, 'get_all')
    def test_get_all_called_once_with_default(self, mock_get_all):
        self.client.get_all()
        mock_get_all.assert_called_once_with(0, -1, filter='', sort='', scope_uris='')

    @mock.patch.object(ResourceHelper, 'create')
    def test_create_called_once(self, mock_create):
        eg_initial = self.MINIMAL_DATA_FOR_EG_CREATION.copy()

        self.client.create(eg_initial)
        default_values = self.client._get_default_values()
        eg_expected = self.MINIMAL_DATA_FOR_EG_CREATION.copy()
        eg_expected.update(default_values)

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

    @mock.patch.object(ResourceHelper, 'delete')
    def test_delete_called_once(self, mock_delete):
        self.client.delete()

        mock_delete.assert_called_once_with(self.client.data["uri"], custom_headers=None, force=False, timeout=-1)

    @mock.patch.object(Resource, 'ensure_resource_data')
    @mock.patch.object(ResourceHelper, 'update')
    def test_update_called_once(self, mock_update, mock_ensure_client):
        eg_initial = self.MINIMAL_DATA_FOR_EG_CREATION.copy()

        self.client.update(eg_initial)

        eg_expected = self.MINIMAL_DATA_FOR_EG_CREATION.copy()
        eg_expected["uri"] = self.uri

        mock_update.assert_called_once_with(eg_expected, self.uri, False, -1, None)

    @mock.patch.object(ResourceHelper, 'update')
    def test_update_script_by_uri_called_once(self, mock_update):
        script_body = "#TEST COMMAND"
        self.client.update_script(script_body)
        mock_update.assert_called_once_with(script_body, uri=self.uri + "/script")
Beispiel #10
0
 def setUp(self):
     self.host = '127.0.0.1'
     self.connection = connection(self.host)
     self.client = EnclosureGroups(self.connection)
     self.uri = "/rest/enclosure-groups/f0a0a113-ec97-41b4-83ce-d7c92b900e7c"
     self.client.data = {"uri": self.uri}
Beispiel #11
0
class EnclosureGroupsTest(unittest.TestCase):
    MINIMAL_DATA_FOR_EG_CREATION = {
        "name":
        "Enclosure Group 1",
        "stackingMode":
        "Enclosure",
        "interconnectBayMappings": [{
            "interconnectBay": 1,
        }, {
            "interconnectBay": 2,
        }, {
            "interconnectBay": 3,
        }, {
            "interconnectBay": 4,
        }, {
            "interconnectBay": 5,
        }, {
            "interconnectBay": 6,
        }, {
            "interconnectBay": 7,
        }, {
            "interconnectBay": 8,
        }]
    }

    def setUp(self):
        self.host = '127.0.0.1'
        self.connection = connection(self.host)
        self.client = EnclosureGroups(self.connection)
        self.uri = "/rest/enclosure-groups/f0a0a113-ec97-41b4-83ce-d7c92b900e7c"
        self.client.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'
        scope_uris = 'rest/scopes/cd237b60-09e2-45c4-829e-082e318a6d2a'
        self.client.get_all(2, 500, filter, sort, scope_uris)

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

    @mock.patch.object(ResourceHelper, 'get_all')
    def test_get_all_called_once_with_default(self, mock_get_all):
        self.client.get_all()
        mock_get_all.assert_called_once_with(0,
                                             -1,
                                             filter='',
                                             sort='',
                                             scope_uris='')

    @mock.patch.object(ResourceHelper, 'create')
    def test_create_called_once(self, mock_create):
        eg_initial = self.MINIMAL_DATA_FOR_EG_CREATION.copy()

        self.client.create(eg_initial)
        default_values = self.client._get_default_values()
        eg_expected = self.MINIMAL_DATA_FOR_EG_CREATION.copy()
        eg_expected.update(default_values)

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

    @mock.patch.object(ResourceHelper, 'delete')
    def test_delete_called_once(self, mock_delete):
        self.client.delete()

        mock_delete.assert_called_once_with(self.client.data["uri"],
                                            custom_headers=None,
                                            force=False,
                                            timeout=-1)

    @mock.patch.object(Resource, 'ensure_resource_data')
    @mock.patch.object(ResourceHelper, 'update')
    def test_update_called_once(self, mock_update, mock_ensure_client):
        eg_initial = self.MINIMAL_DATA_FOR_EG_CREATION.copy()

        self.client.update(eg_initial)

        eg_expected = self.MINIMAL_DATA_FOR_EG_CREATION.copy()
        eg_expected["uri"] = self.uri

        mock_update.assert_called_once_with(eg_expected, self.uri, False, -1,
                                            None)

    @mock.patch.object(ResourceHelper, 'update')
    def test_update_script_by_uri_called_once(self, mock_update):
        script_body = "#TEST COMMAND"
        self.client.update_script(script_body)
        mock_update.assert_called_once_with(script_body,
                                            uri=self.uri + "/script")