Skip to content

Commit 1d54287

Browse files
committed
Avoid reporting all the data from HTTP request
Report the url and just the data item index instead.
1 parent 901cd36 commit 1d54287

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/retasc/models/inputs/http.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ class Http(HttpBase, InputBase):
3434
default="http_data",
3535
)
3636

37-
def _make_request(self, context):
37+
def _make_request(self, url: str, context):
3838
"""Make HTTP request and return the response."""
39-
url = context.template.render(self.url)
4039
headers = render_template_dict(self.headers, context)
4140
params = render_template_dict(self.params, context)
4241
data = render_templates(self.data, context)
@@ -64,18 +63,20 @@ def _extract_items(self, response, context):
6463
return items
6564

6665
def values(self, context) -> Iterator[dict]:
67-
response = self._make_request(context)
66+
url = context.template.render(self.url)
67+
response = self._make_request(url, context)
6868
items = self._extract_items(response, context)
6969

7070
for index, item in enumerate(items):
7171
yield {
72+
"url": url,
7273
"http_item": item,
7374
"http_response": response,
7475
"http_item_index": index,
7576
}
7677

7778
def report_vars(self, values: dict) -> dict:
7879
return {
79-
"http_item": values.get("http_item"),
80+
"url": self.url,
8081
"http_item_index": values.get("http_item_index"),
8182
}

tests/test_input_http.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,7 @@ def test_http_input_report_vars(mock_context, requests_mock):
227227
values = list(http_input.values(mock_context))
228228

229229
report_vars = http_input.report_vars(values[0])
230-
assert report_vars == {
231-
"http_item": {"id": 1, "name": "item1"},
232-
"http_item_index": 0,
233-
}
230+
assert report_vars == {"url": url, "http_item_index": 0}
234231

235232

236233
def test_http_input_http_error(mock_context, requests_mock):

0 commit comments

Comments
 (0)