manager: fix check type form & pricing fields mutex (#64778)

This commit is contained in:
Lauréline Guérin 2022-05-03 11:16:57 +02:00
parent aee7d8c9f8
commit ff2f877557
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 5 additions and 1 deletions

View File

@ -82,7 +82,7 @@ class NewCheckTypeForm(forms.ModelForm):
def clean(self):
super().clean()
if self.cleaned_data.get('pricing') and self.cleaned_data.get('pricing_rate'):
if self.cleaned_data.get('pricing') is not None and self.cleaned_data.get('pricing_rate') is not None:
raise ValidationError(_('Please choose between pricing and pricing rate.'))

View File

@ -145,6 +145,10 @@ def test_add_check_type_pricing(settings, app, admin_user):
resp.form['pricing_rate'] = 150
resp = resp.form.submit()
assert resp.context['form'].errors['__all__'] == ['Please choose between pricing and pricing rate.']
resp.form['pricing'] = 0
resp.form['pricing_rate'] = 0
resp = resp.form.submit()
assert resp.context['form'].errors['__all__'] == ['Please choose between pricing and pricing rate.']
resp.form['pricing'] = 42
resp.form['pricing_rate'] = None
resp = resp.form.submit()