0001-data_sources-do-not-crash-on-unknown-source-type-360.patch
tests/test_datasource.py | ||
---|---|---|
285 | 285 |
assert 'Error loading JSON data source' in caplog.records[-1].message |
286 | 286 |
assert 'error' in caplog.records[-1].message |
287 | 287 | |
288 |
def test_json_datasource_no_type(http_requests, caplog): |
|
289 |
datasource = {'value': "https://whatever.com/json"} |
|
290 |
assert data_sources.get_items(datasource) == [] |
|
291 |
assert not data_sources.get_object(datasource) |
|
292 |
assert "Data source %s has no known type" % datasource in caplog.records[-1].message |
|
293 | ||
288 | 294 |
def test_json_datasource_bad_url_scheme(caplog): |
289 | 295 |
datasource = {'type': 'json', 'value': ''} |
290 | 296 |
assert data_sources.get_items(datasource) == [] |
wcs/data_sources.py | ||
---|---|---|
127 | 127 |
items.sort(key=lambda x: qommon.misc.simplify(x['text'])) |
128 | 128 |
return items |
129 | 129 | |
130 |
if data_source.get('type') not in ('json', 'jsonp', 'formula'): |
|
130 |
if data_source.get('type') and data_source.get('type') not in ('json', 'jsonp', 'formula'):
|
|
131 | 131 |
# named data source |
132 | 132 |
named_data_source = NamedDataSource.get_by_slug(data_source['type']) |
133 | 133 |
if named_data_source.cache_duration: |
... | ... | |
238 | 238 |
if not data_source: |
239 | 239 |
return None |
240 | 240 |
ds_type = data_source.get('type') |
241 |
if not ds_type: |
|
242 |
get_logger().warn('Data source %s has no known type' % data_source) |
|
243 |
return None |
|
241 | 244 |
if ds_type in ('json', 'jsonp', 'formula'): |
242 | 245 |
named_data_source = NamedDataSource() |
243 | 246 |
named_data_source.data_source = data_source |
244 |
- |