Ejemplo n.º 1
0
    def test_update(self):
        """
        Tests if it updates device information in Server Density.
        """
        with patch.dict(serverdensity_device.__pillar__, {"serverdensity": {"api_token": "salt"}}):
            MockRequests.flag = 0
            MockJson.flag = 0
            self.assertTrue(serverdensity_device.update("51f7eaf", name="lama"))

            MockJson.flag = 1
            self.assertRaises(CommandExecutionError, serverdensity_device.update, "51f7eaf", name="lama")

            MockRequests.flag = 1
            self.assertIsNone(serverdensity_device.update("51f7eaf", name="lama"))
Ejemplo n.º 2
0
    def test_update(self):
        '''
        Tests if it updates device information in Server Density.
        '''
        with patch.dict(serverdensity_device.__pillar__,
                        {'serverdensity': {'api_token': 'salt'}}):
            MockRequests.flag = 0
            MockJson.flag = 0
            self.assertTrue(serverdensity_device.update('51f7eaf', name='lama'))

            MockJson.flag = 1
            self.assertRaises(CommandExecutionError,
                              serverdensity_device.update, '51f7eaf',
                              name='lama')

            MockRequests.flag = 1
            self.assertIsNone(serverdensity_device.update('51f7eaf',
                                                          name='lama'))
Ejemplo n.º 3
0
    def test_update(self):
        '''
        Tests if it updates device information in Server Density.
        '''
        with patch.dict(serverdensity_device.__pillar__,
                        {'serverdensity': {'api_token': 'salt'}}):
            MockRequests.flag = 0
            MockJson.flag = 0
            self.assertTrue(serverdensity_device.update('51f7eaf', name='lama'))

            MockJson.flag = 1
            self.assertRaises(CommandExecutionError,
                              serverdensity_device.update, '51f7eaf',
                              name='lama')

            MockRequests.flag = 1
            self.assertIsNone(serverdensity_device.update('51f7eaf',
                                                          name='lama'))
Ejemplo n.º 4
0
    def test_update(self):
        """
        Tests if it updates device information in Server Density.
        """
        with patch.dict(serverdensity_device.__pillar__,
                        {"serverdensity": {
                            "api_token": "salt"
                        }}):
            MockRequests.flag = 0
            self.assertTrue(serverdensity_device.update("51f7eaf",
                                                        name="lama"))

            with patch.object(salt.utils.json, "loads", self.mock_json_loads):
                self.assertRaises(
                    CommandExecutionError,
                    serverdensity_device.update,
                    "51f7eaf",
                    name="lama",
                )

            MockRequests.flag = 1
            self.assertIsNone(
                serverdensity_device.update("51f7eaf", name="lama"))