def test_present_absent(rabbitmq_container): """ Test rabbitmq_policy.present and rabbitmq_policy.absent """ with patch.dict(rabbitmq.__salt__, {"pkg.version": MagicMock(return_value="3.8")}): # Clear the policy ret = rabbitmq_policy.present( name="HA", pattern=".*", definition={"ha-mode": "all"} ) expected = { "name": "HA", "result": True, "comment": ( 'Setting policy "HA" for pattern ".*" to "{"ha-mode": "all"}" with' ' priority "0" for vhost "/" ...\n' ), "changes": {"old": {}, "new": "HA"}, } assert ret == expected # Delete the policy ret = rabbitmq_policy.absent("HA") expected = { "name": "HA", "result": True, "comment": "Deleted", "changes": {"new": "", "old": "HA"}, } assert ret == expected
def test_absent(self): ''' Test to ensure the named policy is absent. ''' name = 'HA' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} mock = MagicMock(side_effect=[False, True]) with patch.dict(rabbitmq_policy.__salt__, {'rabbitmq.policy_exists': mock}): comt = ('Policy / HA is not present') ret.update({'comment': comt}) self.assertDictEqual(rabbitmq_policy.absent(name), ret) with patch.dict(rabbitmq_policy.__opts__, {'test': True}): comt = ('Removing policy / HA') ret.update({'comment': comt, 'result': None}) self.assertDictEqual(rabbitmq_policy.absent(name), ret)
def test_absent(self): ''' Test to ensure the named policy is absent. ''' name = 'HA' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} mock = MagicMock(side_effect=[False, True]) with patch.dict(rabbitmq_policy.__salt__, {'rabbitmq.policy_exists': mock}): comt = ('Policy / HA is not present') ret.update({'comment': comt}) self.assertDictEqual(rabbitmq_policy.absent(name), ret) with patch.dict(rabbitmq_policy.__opts__, {'test': True}): comt = ('Removing policy / HA') ret.update({'comment': comt, 'result': None}) self.assertDictEqual(rabbitmq_policy.absent(name), ret)
def test_absent(self): ''' Test to ensure the named policy is absent. ''' name = 'HA' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} mock = MagicMock(side_effect=[False, True]) with patch.dict(rabbitmq_policy.__salt__, {'rabbitmq.policy_exists': mock}): comment = 'Policy \'/ HA\' is not present.' ret.update({'comment': comment}) self.assertDictEqual(rabbitmq_policy.absent(name), ret) with patch.dict(rabbitmq_policy.__opts__, {'test': True}): comment = 'Policy \'/ HA\' will be removed.' changes = {'new': '', 'old': 'HA'} ret.update({'comment': comment, 'result': None, 'changes': changes}) self.assertDictEqual(rabbitmq_policy.absent(name), ret)
def test_absent(self): ''' Test to ensure the named policy is absent. ''' name = 'HA' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} mock = MagicMock(side_effect=[False, True]) with patch.dict(rabbitmq_policy.__salt__, {'rabbitmq.policy_exists': mock}): comment = 'Policy \'/ HA\' is not present.' ret.update({'comment': comment}) self.assertDictEqual(rabbitmq_policy.absent(name), ret) with patch.dict(rabbitmq_policy.__opts__, {'test': True}): comment = 'Policy \'/ HA\' will be removed.' changes = {'new': '', 'old': 'HA'} ret.update({'comment': comment, 'result': None, 'changes': changes}) self.assertDictEqual(rabbitmq_policy.absent(name), ret)
def test_absent(self): """ Test to ensure the named policy is absent. """ name = "HA" ret = {"name": name, "changes": {}, "result": True, "comment": ""} mock = MagicMock(side_effect=[False, True]) with patch.dict(rabbitmq_policy.__salt__, {"rabbitmq.policy_exists": mock}): comment = "Policy '/ HA' is not present." ret.update({"comment": comment}) self.assertDictEqual(rabbitmq_policy.absent(name), ret) with patch.dict(rabbitmq_policy.__opts__, {"test": True}): comment = "Policy '/ HA' will be removed." changes = {"new": "", "old": "HA"} ret.update({ "comment": comment, "result": None, "changes": changes }) self.assertDictEqual(rabbitmq_policy.absent(name), ret)
def test_absent(rabbitmq_container): """ Test rabbitmq_policy.absent """ with patch.dict(rabbitmq.__salt__, {"pkg.version": MagicMock(return_value="3.8")}): # Delete the policy ret = rabbitmq_policy.absent("HA") expected = { "name": "HA", "result": True, "comment": "Policy '/ HA' is not present.", "changes": {}, } assert ret == expected