def evaluateTarget(requestContext, targets): if not isinstance(targets, list): targets = [targets] pathExpressions = extractPathExpressions(requestContext, targets) prefetchData(requestContext, pathExpressions) seriesList = [] for target in targets: if not target: continue if isinstance(target, six.string_types): if not target.strip(): continue target = grammar.parseString(target) try: result = evaluateTokens(requestContext, target) except InputParameterError as e: e.setTargets(requestContext.get('targets', [])) e.setSourceIdHeaders(requestContext.get('sourceIdHeaders', {})) raise # we have to return a list of TimeSeries objects if isinstance(result, TimeSeries): seriesList.append(result) elif result: seriesList.extend(result) return seriesList
def test_prefetchData(self): # STORE.finders has no non-local finders results = prefetchData({}, []) self.assertEqual(results, None) # STORE.fetch returns list with None value with patch('graphite.render.datalib.STORE.fetch', lambda *_: [None]): startTime = datetime(1970, 1, 1, 0, 10, 0, 0, pytz.timezone(settings.TIME_ZONE)) endTime = datetime(1970, 1, 1, 0, 20, 0, 0, pytz.timezone(settings.TIME_ZONE)) now = datetime(1970, 1, 1, 0, 20, 0, 0, pytz.timezone(settings.TIME_ZONE)) requestContext = { 'startTime': startTime, 'endTime': endTime, 'now': now, 'prefetched': { 'somekey': 'somedata', }, } prefetchData(requestContext, ['test']) self.assertEqual( requestContext['prefetched'][timebounds(requestContext)], {})
def evaluateTarget(requestContext, targets): if not isinstance(targets, list): targets = [targets] pathExpressions = extractPathExpressions(requestContext, targets) prefetchData(requestContext, pathExpressions) seriesList = [] for target in targets: if not target: continue if isinstance(target, six.string_types): if not target.strip(): continue target = grammar.parseString(target) result = evaluateTokens(requestContext, target) # we have to return a list of TimeSeries objects if isinstance(result, TimeSeries): seriesList.append(result) elif result: seriesList.extend(result) return seriesList
def evaluateTarget(requestContext, targets): if not isinstance(targets, list): targets = [targets] pathExpressions = extractPathExpressions(requestContext, targets) prefetchData(requestContext, pathExpressions) seriesList = [] for target in targets: if not target: continue if isinstance(target, six.string_types): if not target.strip(): continue target = grammar.parseString(target) result = evaluateTokens(requestContext, target) # we have to return a list of TimeSeries objects if isinstance(result, TimeSeries): seriesList.append(result) elif result: seriesList.extend(result) return seriesList
def test_prefetchData(self): # STORE.finders has no non-local finders results = prefetchData({}, []) self.assertEqual(results, None) # STORE.fetch returns list with None value with patch('graphite.render.datalib.STORE.fetch', lambda *_: [None]): startTime = datetime(1970, 1, 1, 0, 10, 0, 0, pytz.timezone(settings.TIME_ZONE)) endTime = datetime(1970, 1, 1, 0, 20, 0, 0, pytz.timezone(settings.TIME_ZONE)) now = datetime(1970, 1, 1, 0, 20, 0, 0, pytz.timezone(settings.TIME_ZONE)) requestContext = { 'startTime': startTime, 'endTime': endTime, 'now': now, 'prefetched': { 'somekey': 'somedata', }, } prefetchData(requestContext, ['test']) self.assertEqual(requestContext['prefetched'][timebounds(requestContext)], {})