Skip to content

Commit

Permalink
Merge pull request #2223 from DanCech/handle-none
Browse files Browse the repository at this point in the history
handle case when node.fetch returns None
  • Loading branch information
DanCech committed Feb 5, 2018
2 parents a01dbe9 + f275242 commit b8f9aed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 9 additions & 4 deletions webapp/graphite/finders/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,31 @@ def fetch(self, patterns, start_time, end_time, now=None, requestContext=None):
for pattern in patterns
]

result = []
results = []

for node, query in self.find_multi(queries):
if not isinstance(node, LeafNode):
continue

time_info, values = node.fetch(
result = node.fetch(
start_time, end_time,
now=now, requestContext=requestContext
)

result.append({
if result is None:
continue

time_info, values = result

results.append({
'pathExpression': query.pattern,
'path': node.path,
'name': node.path,
'time_info': time_info,
'values': values,
})

return result
return results

def auto_complete_tags(self, exprs, tagPrefix=None, limit=None, requestContext=None):
return []
Expand Down
3 changes: 3 additions & 0 deletions webapp/tests/test_finders.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ def test_standard_finder(self,scandir_mock):
self.assertEqual(len(list(nodes)), 1)
self.assertEqual(scandir_mock.call_count, 1)

results = finder.fetch(['foo'], 0, 1)
self.assertEqual(results, [])

finally:
scandir_mock.call_count = 0
self.wipe_whisper()
Expand Down

0 comments on commit b8f9aed

Please sign in to comment.