def test_absent(self): ''' Test to ensure the Kinesis stream does not exist. ''' name = 'new_stream' ret = {'name': name, 'result': True, 'changes': {}, 'comment': ''} mock = MagicMock(side_effect=[{'result': False}, {'result': True}, {'result': True}]) mock_bool = MagicMock(return_value={'result': True}) with patch.dict(boto_kinesis.__salt__, {'boto_kinesis.exists': mock, 'boto_kinesis.delete_stream': mock_bool}): comt = ('Kinesis stream {0} does not exist'.format(name)) ret.update({'comment': comt}) self.assertDictEqual(boto_kinesis.absent(name), ret) with patch.dict(boto_kinesis.__opts__, {'test': True}): comt = ('Kinesis stream {0} would be deleted'.format(name)) ret.update({'comment': comt, 'result': None}) self.assertDictEqual(boto_kinesis.absent(name), ret) changes = {'new': 'Stream {0} deleted'.format(name), 'old': 'Stream {0} exists'.format(name)} with patch.dict(boto_kinesis.__opts__, {'test': False}): comt = ('Deleted stream {0}'.format(name)) ret.update({'comment': comt, 'result': True, 'changes': changes}) self.assertDictEqual(boto_kinesis.absent(name), ret)
def test_absent(self): """ Test to ensure the Kinesis stream does not exist. """ name = "new_stream" ret = {"name": name, "result": True, "changes": {}, "comment": ""} mock = MagicMock(side_effect=[{"result": False}, {"result": True}, {"result": True}]) mock_bool = MagicMock(return_value={"result": True}) with patch.dict( boto_kinesis.__salt__, {"boto_kinesis.exists": mock, "boto_kinesis.delete_stream": mock_bool}, ): comt = "Kinesis stream {} does not exist".format(name) ret.update({"comment": comt}) assert boto_kinesis.absent(name) == ret with patch.dict(boto_kinesis.__opts__, {"test": True}): comt = "Kinesis stream {} would be deleted".format(name) ret.update({"comment": comt, "result": None}) assert boto_kinesis.absent(name) == ret changes = { "new": "Stream {} deleted".format(name), "old": "Stream {} exists".format(name), } with patch.dict(boto_kinesis.__opts__, {"test": False}): comt = "Deleted stream {}".format(name) ret.update({"comment": comt, "result": True, "changes": changes}) assert boto_kinesis.absent(name) == ret