Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions test_elasticsearch/test_server/test_rest_api_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,16 +411,21 @@ def _resolve(self, value):
return value

def _lookup(self, path):
# fetch the possibly nested value from last_response
value = self.last_response
if path == "$body":
return value
return self.last_response
if path.startswith("$"):
value = None
else:
value = self.last_response
path = path.replace(r"\.", "\1")
for step in path.split("."):
if not step:
continue
# We check body again to handle E.g. '$body.$backing_index.data_stream'
if step.startswith("$body"):
if step == "$body":
assert value is None
# fetch the possibly nested value from last_response
value = self.last_response
continue
step = step.replace("\1", ".")
step = self._resolve(step)
Expand All @@ -432,11 +437,15 @@ def _lookup(self, path):
step = int(step)
assert isinstance(value, list)
assert len(value) > step
value = value[step]
elif step == "_arbitrary_key_":
return list(value.keys())[0]
else:
elif isinstance(step, string_types) and isinstance(value, dict):
assert step in value
value = value[step]
value = value[step]
else:
assert value is None
value = step
return value

def _feature_enabled(self, name):
Expand Down