示例#1
0
    def test_add_license(self):
        """
        Test to add a license
        """
        with patch.object(powerpath, "has_powerpath", return_value=False):
            self.assertDictEqual(
                powerpath.add_license("key"),
                {
                    "output": "PowerPath is not installed",
                    "result": False,
                    "retcode": -1,
                },
            )

        mock = MagicMock(return_value={"retcode": 1, "stderr": "stderr"})
        with patch.object(powerpath, "has_powerpath", return_value=True):
            with patch.dict(powerpath.__salt__, {"cmd.run_all": mock}):
                self.assertDictEqual(
                    powerpath.add_license("key"),
                    {
                        "output": "stderr",
                        "result": False,
                        "retcode": 1
                    },
                )
示例#2
0
    def test_add_license(self):
        '''
        Test to add a license
        '''
        with patch.object(powerpath, 'has_powerpath', return_value=False):
            self.assertDictEqual(powerpath.add_license('key'),
                                 {'output': 'PowerPath is not installed',
                                  'result': False, 'retcode': -1})

        mock = MagicMock(return_value={'retcode': 1, 'stderr': 'stderr'})
        with patch.object(powerpath, 'has_powerpath', return_value=True):
            with patch.dict(powerpath.__salt__, {'cmd.run_all': mock}):
                self.assertDictEqual(powerpath.add_license('key'),
                                     {'output': 'stderr', 'result': False,
                                      'retcode': 1})