def test_present(self): ''' Test to ensure the RackSpace queue exists. ''' name = 'myqueue' provider = 'my-pyrax' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} mock_dct = MagicMock(side_effect=[{provider: {'salt': True}}, {provider: {'salt': False}}, {provider: {'salt': False}}, False]) with patch.dict(pyrax_queues.__salt__, {'cloud.action': mock_dct}): comt = ('{0} present.'.format(name)) ret.update({'comment': comt}) self.assertDictEqual(pyrax_queues.present(name, provider), ret) with patch.dict(pyrax_queues.__opts__, {'test': True}): comt = ('Rackspace queue myqueue is set to be created.') ret.update({'comment': comt, 'result': None}) self.assertDictEqual(pyrax_queues.present(name, provider), ret) with patch.dict(pyrax_queues.__opts__, {'test': False}): comt = ('Failed to create myqueue Rackspace queue.') ret.update({'comment': comt, 'result': False}) self.assertDictEqual(pyrax_queues.present(name, provider), ret)
def test_present(self): """ Test to ensure the RackSpace queue exists. """ name = "myqueue" provider = "my-pyrax" ret = {"name": name, "changes": {}, "result": True, "comment": ""} mock_dct = MagicMock( side_effect=[ {provider: {"salt": True}}, {provider: {"salt": False}}, {provider: {"salt": False}}, False, ] ) with patch.dict(pyrax_queues.__salt__, {"cloud.action": mock_dct}): comt = "{0} present.".format(name) ret.update({"comment": comt}) self.assertDictEqual(pyrax_queues.present(name, provider), ret) with patch.dict(pyrax_queues.__opts__, {"test": True}): comt = "Rackspace queue myqueue is set to be created." ret.update({"comment": comt, "result": None}) self.assertDictEqual(pyrax_queues.present(name, provider), ret) with patch.dict(pyrax_queues.__opts__, {"test": False}): comt = "Failed to create myqueue Rackspace queue." ret.update({"comment": comt, "result": False}) self.assertDictEqual(pyrax_queues.present(name, provider), ret)