|
27 | 27 | from typing import List |
28 | 28 | from typing import Optional |
29 | 29 | from typing import Tuple |
| 30 | +from unittest.mock import MagicMock |
30 | 31 |
|
31 | 32 | import requests |
32 | 33 | import saneyaml |
@@ -67,32 +68,8 @@ def fetch_yaml(url): |
67 | 68 | return saneyaml.load(response.content) |
68 | 69 |
|
69 | 70 |
|
70 | | -# FIXME: this is NOT how etags work . |
71 | | -# We should instead send the proper HTTP header |
72 | | -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-None-Match |
73 | | -# and integrate this finely in the processing as this typically needs to use |
74 | | -# streaming=True requests, and proper handling of the HTTP return code |
75 | | -# In all cases this ends up being a single request, not a HEADD followed |
76 | | -# by another real request |
77 | | -def create_etag(data_src, url, etag_key): |
78 | | - """ |
79 | | - Etags are like hashes of web responses. For a data source `data_src`, |
80 | | - we maintain (url, etag) mappings in the DB. `create_etag` creates |
81 | | - (`url`, etag) pair. If a (`url`, etag) already exists then the code |
82 | | - skips processing the response further to avoid duplicate work. |
83 | | -
|
84 | | - `etag_key` is the name of header which contains the etag for the url. |
85 | | - """ |
86 | | - etag = requests.head(url).headers.get(etag_key) |
87 | | - if not etag: |
88 | | - return True |
89 | | - |
90 | | - elif url in data_src.config.etags: |
91 | | - if data_src.config.etags[url] == etag: |
92 | | - return False |
93 | | - |
94 | | - data_src.config.etags[url] = etag |
95 | | - return True |
| 71 | +# FIXME: Remove this entirely after complete importer-improver migration |
| 72 | +create_etag = MagicMock() |
96 | 73 |
|
97 | 74 |
|
98 | 75 | def contains_alpha(string): |
|
0 commit comments