dataviz: do not raise error in check_validity (#65615)
gitea-wip/combo/pipeline/head There was a failure building this commit Details
gitea/combo/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Valentin Deniaud 2022-05-24 14:52:08 +02:00 committed by Frédéric Péters
parent d05406d9a0
commit f3727f829d
2 changed files with 13 additions and 2 deletions

View File

@ -302,7 +302,7 @@ class ChartNgCell(CellBase):
resp = None
try:
resp = self.get_statistic_data()
except RequestException:
except (RequestException, MissingRequest, MissingVariable):
pass
self.set_validity_from_url(

View File

@ -2121,7 +2121,7 @@ def test_chartng_cell_new_api_filter_params_page_variables_table(new_api_statist
def test_dataviz_check_validity(nocache):
page = Page.objects.create(title='One', slug='index')
page = Page.objects.create(title='One', slug='index', extra_variables={'foo': 'bar'})
stat = Statistic.objects.create(url='https://stat.com/stats/1/')
cell = ChartNgCell.objects.create(page=page, order=1, placeholder='content', statistic=stat)
@ -2133,6 +2133,17 @@ def test_dataviz_check_validity(nocache):
cell.check_validity()
assert ValidityInfo.objects.exists() is False
# cell using page variable is valid even if it cannot be evaluated
cell.filter_params = {'test': 'variable:foo'}
cell.save()
with HTTMock(url_mock):
cell.check_validity()
assert ValidityInfo.objects.exists() is False
cell.filter_params.clear()
cell.save()
@urlmatch(scheme='https', netloc=r'stat.com', path='/stats/1/')
def url_mock2(url, request):
return {'content': json.dumps({'data': [], 'err': 1}), 'status_code': 404}