Esempio n. 1
0
    def test_absent(self):
        '''
            Test to ensure that the named group is absent
        '''
        ret = {'name': 'salt', 'changes': {}, 'result': True, 'comment': {}}
        mock = MagicMock(side_effect=[True, True, True, False])
        with patch.dict(group.__salt__, {'group.info': mock}):
            with patch.dict(group.__opts__, {"test": True}):
                ret.update({
                    'result': None,
                    'comment': 'Group salt is set for removal'
                })
                self.assertDictEqual(group.absent("salt"), ret)

            with patch.dict(group.__opts__, {"test": False}):
                mock = MagicMock(side_effect=[True, False])
                with patch.dict(group.__salt__, {'group.delete': mock}):
                    ret.update({
                        'result': True,
                        'changes': {
                            'salt': ''
                        },
                        'comment': 'Removed group salt'
                    })
                    self.assertDictEqual(group.absent('salt'), ret)

                    ret.update({
                        'changes': {},
                        'result': False,
                        'comment': 'Failed to remove group salt'
                    })
                    self.assertDictEqual(group.absent('salt'), ret)

            ret.update({'result': True, 'comment': 'Group not present'})
            self.assertDictEqual(group.absent('salt'), ret)
Esempio n. 2
0
    def test_absent(self):
        """
            Test to ensure that the named group is absent
        """
        ret = {"name": "salt", "changes": {}, "result": True, "comment": {}}
        mock = MagicMock(side_effect=[True, True, True, False])
        with patch.dict(group.__salt__, {"group.info": mock}):
            with patch.dict(group.__opts__, {"test": True}):
                ret.update({
                    "result": None,
                    "comment": "Group salt is set for removal"
                })
                self.assertDictEqual(group.absent("salt"), ret)

            with patch.dict(group.__opts__, {"test": False}):
                mock = MagicMock(side_effect=[True, False])
                with patch.dict(group.__salt__, {"group.delete": mock}):
                    ret.update({
                        "result": True,
                        "changes": {
                            "salt": ""
                        },
                        "comment": "Removed group salt",
                    })
                    self.assertDictEqual(group.absent("salt"), ret)

                    ret.update({
                        "changes": {},
                        "result": False,
                        "comment": "Failed to remove group salt",
                    })
                    self.assertDictEqual(group.absent("salt"), ret)

            ret.update({"result": True, "comment": "Group not present"})
            self.assertDictEqual(group.absent("salt"), ret)
Esempio n. 3
0
    def test_absent(self):
        '''
            Test to ensure that the named group is absent
        '''
        ret = {'name': 'salt',
               'changes': {},
               'result': True,
               'comment': {}
               }
        mock = MagicMock(side_effect=[True, True, True, False])
        with patch.dict(group.__salt__, {'group.info': mock}):
            with patch.dict(group.__opts__, {"test": True}):
                ret.update({'result': None,
                            'comment': 'Group salt is set for removal'})
                self.assertDictEqual(group.absent("salt"), ret)

            with patch.dict(group.__opts__, {"test": False}):
                mock = MagicMock(side_effect=[True, False])
                with patch.dict(group.__salt__, {'group.delete': mock}):
                    ret.update({'result': True, 'changes': {'salt': ''},
                                'comment': 'Removed group salt'})
                    self.assertDictEqual(group.absent('salt'), ret)

                    ret.update({'changes': {}, 'result': False,
                                'comment': 'Failed to remove group salt'})
                    self.assertDictEqual(group.absent('salt'), ret)

            ret.update({'result': True,
                        'comment': 'Group not present'})
            self.assertDictEqual(group.absent('salt'), ret)