tests: fix useless assertions on chart cell form fields (#85654)
This commit is contained in:
parent
8a10f3eab2
commit
b20464820a
|
@ -1694,31 +1694,35 @@ def test_chartng_cell_manager(app, admin_user, statistics):
|
|||
|
||||
cell = ChartNgCell.objects.create(page=page, order=1, placeholder='content')
|
||||
resp = app.get('/manage/pages/%s/' % page.id)
|
||||
assert 'time_range' not in resp.form.fields
|
||||
assert 'time_range_start' not in resp.form.fields
|
||||
assert 'time_range_end' not in resp.form.fields
|
||||
assert 'time_range_start_template' not in resp.form.fields
|
||||
assert 'time_range_end_template_end' not in resp.form.fields
|
||||
field_prefix = 'cdataviz_chartngcell-%s-' % cell.id
|
||||
|
||||
assert field_prefix + 'statistic' in resp.form.fields
|
||||
assert field_prefix + 'time_range' not in resp.form.fields
|
||||
assert field_prefix + 'time_range_start' not in resp.form.fields
|
||||
assert field_prefix + 'time_range_end' not in resp.form.fields
|
||||
assert field_prefix + 'time_range_start_template' not in resp.form.fields
|
||||
assert field_prefix + 'time_range_end_template_end' not in resp.form.fields
|
||||
|
||||
cell.statistic = Statistic.objects.get(slug='example')
|
||||
cell.save()
|
||||
resp = app.get('/manage/pages/%s/' % page.id)
|
||||
statistics_field = resp.form['cdataviz_chartngcell-%s-statistic' % cell.id]
|
||||
statistics_field = resp.form[field_prefix + 'statistic']
|
||||
# available visualizations and a blank choice
|
||||
assert len(statistics_field.options) == len(VISUALIZATION_JSON) + 1
|
||||
assert statistics_field.value == str(cell.statistic.pk)
|
||||
assert statistics_field.options[1][2] == 'test: eighth visualization (duration)'
|
||||
assert not 'Unavailable Stat' in resp.text
|
||||
assert 'time_range' not in resp.form.fields
|
||||
assert 'time_range_start' not in resp.form.fields
|
||||
assert 'time_range_end' not in resp.form.fields
|
||||
assert 'time_range_start_template' not in resp.form.fields
|
||||
assert 'time_range_end_template_end' not in resp.form.fields
|
||||
|
||||
assert field_prefix + 'time_range' not in resp.form.fields
|
||||
assert field_prefix + 'time_range_start' not in resp.form.fields
|
||||
assert field_prefix + 'time_range_end' not in resp.form.fields
|
||||
assert field_prefix + 'time_range_start_template' not in resp.form.fields
|
||||
assert field_prefix + 'time_range_end_template_end' not in resp.form.fields
|
||||
|
||||
cell.statistic = Statistic.objects.get(slug='unavailable-stat')
|
||||
cell.save()
|
||||
resp = app.get('/manage/pages/%s/' % page.id)
|
||||
statistics_field = resp.form['cdataviz_chartngcell-%s-statistic' % cell.id]
|
||||
statistics_field = resp.form[field_prefix + 'statistic']
|
||||
# available visualizations, a blank choice and the current unavailable visualization
|
||||
assert len(statistics_field.options) == len(VISUALIZATION_JSON) + 2
|
||||
assert 'Unavailable Stat' in resp.text
|
||||
|
@ -2000,13 +2004,13 @@ def test_chartng_cell_manager_subfilters(app, admin_user, new_api_statistics):
|
|||
manager_submit_cell(resp.form)
|
||||
|
||||
assert len(new_api_mock.call['requests']) == 1
|
||||
assert 'menu' not in resp.form.fields
|
||||
assert field_prefix + 'menu' not in resp.form.fields
|
||||
|
||||
resp.form[field_prefix + 'form'] = 'error'
|
||||
manager_submit_cell(resp.form)
|
||||
|
||||
assert len(new_api_mock.call['requests']) == 2
|
||||
assert 'menu' not in resp.form.fields
|
||||
assert field_prefix + 'menu' not in resp.form.fields
|
||||
|
||||
# choice with subfilter
|
||||
resp.form[field_prefix + 'form'] = 'food-request'
|
||||
|
|
Loading…
Reference in New Issue