def test_create(self):
        """
        Tests if it create device in Server Density.
        """
        with patch.dict(serverdensity_device.__pillar__, {"serverdensity": {"api_token": "salt"}}):
            self.assertTrue(serverdensity_device.create("rich_lama", group="lama_band"))

            MockJson.flag = 1
            self.assertRaises(CommandExecutionError, serverdensity_device.create, "rich_lama", group="lama_band")

            MockRequests.flag = 1
            self.assertIsNone(serverdensity_device.create("rich_lama", group="lama_band"))
    def test_create(self):
        '''
        Tests if it create device in Server Density.
        '''
        with patch.dict(serverdensity_device.__pillar__,
                        {'serverdensity': {'api_token': 'salt'}}):
            self.assertTrue(serverdensity_device.create('rich_lama',
                                                        group='lama_band'))

            MockJson.flag = 1
            self.assertRaises(CommandExecutionError,
                              serverdensity_device.create, 'rich_lama',
                              group='lama_band')

            MockRequests.flag = 1
            self.assertIsNone(serverdensity_device.create('rich_lama',
                                                          group='lama_band'))
    def test_create(self):
        '''
        Tests if it create device in Server Density.
        '''
        with patch.dict(serverdensity_device.__pillar__,
                        {'serverdensity': {'api_token': 'salt'}}):
            self.assertTrue(serverdensity_device.create('rich_lama',
                                                        group='lama_band'))

            MockJson.flag = 1
            self.assertRaises(CommandExecutionError,
                              serverdensity_device.create, 'rich_lama',
                              group='lama_band')

            MockRequests.flag = 1
            self.assertIsNone(serverdensity_device.create('rich_lama',
                                                          group='lama_band'))
Exemple #4
0
    def test_create(self):
        """
        Tests if it create device in Server Density.
        """
        with patch.dict(serverdensity_device.__pillar__,
                        {"serverdensity": {
                            "api_token": "salt"
                        }}):
            self.assertTrue(
                serverdensity_device.create("rich_lama", group="lama_band"))

            with patch.object(salt.utils.json, "loads", self.mock_json_loads):
                self.assertRaises(
                    CommandExecutionError,
                    serverdensity_device.create,
                    "rich_lama",
                    group="lama_band",
                )

            MockRequests.flag = 1
            self.assertIsNone(
                serverdensity_device.create("rich_lama", group="lama_band"))