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_service.__salt__, {"lvs.check_service": mock_check, "lvs.delete_service": mock_delete}, ): with patch.dict(lvs_service.__opts__, {"test": True}): comt = "LVS Service lvsrs is present and needs to be removed" ret.update({"comment": comt}) self.assertDictEqual(lvs_service.absent(name), ret) with patch.dict(lvs_service.__opts__, {"test": False}): comt = "LVS Service lvsrs has been removed" ret.update( {"comment": comt, "result": True, "changes": {"lvsrs": "Absent"}} ) self.assertDictEqual(lvs_service.absent(name), ret) comt = "LVS Service lvsrs removed failed(False)" ret.update({"comment": comt, "result": False, "changes": {}}) self.assertDictEqual(lvs_service.absent(name), ret) comt = "LVS Service lvsrs is not present, so it cannot be removed" ret.update({"comment": comt, "result": True}) self.assertDictEqual(lvs_service.absent(name), ret)
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_service.__salt__, {'lvs.check_service': mock_check, 'lvs.delete_service': mock_delete}): with patch.dict(lvs_service.__opts__, {'test': True}): comt = ('LVS Service lvsrs is present and needs to be removed') ret.update({'comment': comt}) self.assertDictEqual(lvs_service.absent(name), ret) with patch.dict(lvs_service.__opts__, {'test': False}): comt = ('LVS Service lvsrs has been removed') ret.update({'comment': comt, 'result': True, 'changes': {'lvsrs': 'Absent'}}) self.assertDictEqual(lvs_service.absent(name), ret) comt = ('LVS Service lvsrs removed failed(False)') ret.update({'comment': comt, 'result': False, 'changes': {}}) self.assertDictEqual(lvs_service.absent(name), ret) comt = ('LVS Service lvsrs is not present, so it cannot be removed') ret.update({'comment': comt, 'result': True}) self.assertDictEqual(lvs_service.absent(name), ret)