Ejemplo n.º 1
0
    def test_absent(self):
        """
        Test to ensure the LVS Real Server in specified service is absent.
        """
        name = "lvsrs"

        ret = {"name": name, "result": None, "comment": "", "changes": {}}

        mock_check = MagicMock(side_effect=[True, True, True, False])
        mock_delete = MagicMock(side_effect=[True, False])
        with patch.dict(
                lvs_server.__salt__,
            {
                "lvs.check_server": mock_check,
                "lvs.delete_server": mock_delete
            },
        ):
            with patch.dict(lvs_server.__opts__, {"test": True}):
                comt = ("LVS Server lvsrs in service None(None) is present"
                        " and needs to be removed")
                ret.update({"comment": comt})
                self.assertDictEqual(lvs_server.absent(name), ret)

            with patch.dict(lvs_server.__opts__, {"test": False}):
                comt = "LVS Server lvsrs in service None(None) " "has been removed"
                ret.update({
                    "comment": comt,
                    "result": True,
                    "changes": {
                        "lvsrs": "Absent"
                    }
                })
                self.assertDictEqual(lvs_server.absent(name), ret)

                comt = "LVS Server lvsrs in service None(None) removed " "failed(False)"
                ret.update({"comment": comt, "result": False, "changes": {}})
                self.assertDictEqual(lvs_server.absent(name), ret)

            comt = ("LVS Server lvsrs in service None(None) is not present,"
                    " so it cannot be removed")
            ret.update({"comment": comt, "result": True})
            self.assertDictEqual(lvs_server.absent(name), ret)
Ejemplo n.º 2
0
    def test_absent(self):
        '''
        Test to ensure the LVS Real Server in specified service is absent.
        '''
        name = 'lvsrs'

        ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}

        mock_check = MagicMock(side_effect=[True, True, True, False])
        mock_delete = MagicMock(side_effect=[True, False])
        with patch.dict(lvs_server.__salt__, {
                'lvs.check_server': mock_check,
                'lvs.delete_server': mock_delete
        }):
            with patch.dict(lvs_server.__opts__, {'test': True}):
                comt = ('LVS Server lvsrs in service None(None) is present'
                        ' and needs to be removed')
                ret.update({'comment': comt})
                self.assertDictEqual(lvs_server.absent(name), ret)

            with patch.dict(lvs_server.__opts__, {'test': False}):
                comt = ('LVS Server lvsrs in service None(None) '
                        'has been removed')
                ret.update({
                    'comment': comt,
                    'result': True,
                    'changes': {
                        'lvsrs': 'Absent'
                    }
                })
                self.assertDictEqual(lvs_server.absent(name), ret)

                comt = ('LVS Server lvsrs in service None(None) removed '
                        'failed(False)')
                ret.update({'comment': comt, 'result': False, 'changes': {}})
                self.assertDictEqual(lvs_server.absent(name), ret)

            comt = ('LVS Server lvsrs in service None(None) is not present,'
                    ' so it cannot be removed')
            ret.update({'comment': comt, 'result': True})
            self.assertDictEqual(lvs_server.absent(name), ret)
Ejemplo n.º 3
0
    def test_absent(self):
        '''
        Test to ensure the LVS Real Server in specified service is absent.
        '''
        name = 'lvsrs'

        ret = {'name': name,
               'result': None,
               'comment': '',
               'changes': {}}

        mock_check = MagicMock(side_effect=[True, True, True, False])
        mock_delete = MagicMock(side_effect=[True, False])
        with patch.dict(lvs_server.__salt__, {'lvs.check_server': mock_check,
                                              'lvs.delete_server': mock_delete}):
            with patch.dict(lvs_server.__opts__, {'test': True}):
                comt = ('LVS Server lvsrs in service None(None) is present'
                        ' and needs to be removed')
                ret.update({'comment': comt})
                self.assertDictEqual(lvs_server.absent(name), ret)

            with patch.dict(lvs_server.__opts__, {'test': False}):
                comt = ('LVS Server lvsrs in service None(None) '
                        'has been removed')
                ret.update({'comment': comt, 'result': True,
                            'changes': {'lvsrs': 'Absent'}})
                self.assertDictEqual(lvs_server.absent(name), ret)

                comt = ('LVS Server lvsrs in service None(None) removed '
                        'failed(False)')
                ret.update({'comment': comt, 'result': False, 'changes': {}})
                self.assertDictEqual(lvs_server.absent(name), ret)

            comt = ('LVS Server lvsrs in service None(None) is not present,'
                    ' so it cannot be removed')
            ret.update({'comment': comt, 'result': True})
            self.assertDictEqual(lvs_server.absent(name), ret)