0002-dataviz-do-not-raise-error-in-check_validity-65615.patch
combo/apps/dataviz/models.py | ||
---|---|---|
302 | 302 |
resp = None |
303 | 303 |
try: |
304 | 304 |
resp = self.get_statistic_data() |
305 |
except RequestException:
|
|
305 |
except (RequestException, MissingRequest, MissingVariable):
|
|
306 | 306 |
pass |
307 | 307 | |
308 | 308 |
self.set_validity_from_url( |
tests/test_dataviz.py | ||
---|---|---|
2114 | 2114 | |
2115 | 2115 | |
2116 | 2116 |
def test_dataviz_check_validity(nocache): |
2117 |
page = Page.objects.create(title='One', slug='index') |
|
2117 |
page = Page.objects.create(title='One', slug='index', extra_variables={'foo': 'bar'})
|
|
2118 | 2118 |
stat = Statistic.objects.create(url='https://stat.com/stats/1/') |
2119 | 2119 |
cell = ChartNgCell.objects.create(page=page, order=1, placeholder='content', statistic=stat) |
2120 | 2120 | |
... | ... | |
2126 | 2126 |
cell.check_validity() |
2127 | 2127 |
assert ValidityInfo.objects.exists() is False |
2128 | 2128 | |
2129 |
# cell using page variable is valid even if it cannot be evaluated |
|
2130 |
cell.filter_params = {'test': 'variable:foo'} |
|
2131 |
cell.save() |
|
2132 | ||
2133 |
with HTTMock(url_mock): |
|
2134 |
cell.check_validity() |
|
2135 |
assert ValidityInfo.objects.exists() is False |
|
2136 | ||
2137 |
cell.filter_params.clear() |
|
2138 |
cell.save() |
|
2139 | ||
2129 | 2140 |
@urlmatch(scheme='https', netloc=r'stat.com', path='/stats/1/') |
2130 | 2141 |
def url_mock2(url, request): |
2131 | 2142 |
return {'content': json.dumps({'data': [], 'err': 1}), 'status_code': 404} |
2132 |
- |