def test_problem_details_error_messages(): form = forms.ProblemDetailsForm( data={} ) assert len(form.errors) == 6 form.errors['product_service'] == [ 'Tell us what you’re trying to export or invest in' ] form.errors['country'] == [ 'Select the country you’re trying to export to' ] form.errors['problem_summary'] == [ 'Tell us about the barrier you’re facing' ] form.errors['impact'] == [ 'Tell us how your business is being affected by the barrier' ] form.errors['resolve_summary'] == [ 'Tell us what you’ve done to resolve your problem, \ even if this is your first step' ] form.errors['eu_exit_related'] == [ 'Tell us if your problem is related to EU Exit' ]
def test_problem_details_form_initial(): form = forms.ProblemDetailsForm() assert form.fields['product_service'].initial is None assert form.fields['country'].initial is None assert form.fields['problem_summary'].initial is None assert form.fields['impact'].initial is None assert form.fields['resolve_summary'].initial is None assert form.fields['eu_exit_related'].initial is None
def test_problem_details_form_serialize(problem_details_form_data): form = forms.ProblemDetailsForm(data=problem_details_form_data) assert form.is_valid() assert form.cleaned_data == { 'location_label': 'Angola', 'problem_cause_label': ['Brexit'], **problem_details_form_data }
def test_problem_details_form_initial(): form = forms.ProblemDetailsForm() assert form.fields['product_service'].initial is None assert form.fields['location'].initial is None assert form.fields['problem_summary'].initial is None assert form.fields['impact'].initial is None assert form.fields['resolve_summary'].initial is None assert form.fields['problem_cause'].initial is None
def test_problem_details_form_mandatory_fields(): form = forms.ProblemDetailsForm(data={}) assert form.fields['product_service'].required is True assert form.fields['country'].required is True assert form.fields['problem_summary'].required is True assert form.fields['impact'].required is True assert form.fields['resolve_summary'].required is True assert form.fields['eu_exit_related'].required is True
def test_problem_details_form_mandatory_fields(): form = forms.ProblemDetailsForm(data={}) assert form.fields['product_service'].required is True assert form.fields['location'].required is True assert form.fields['problem_summary'].required is True assert form.fields['impact'].required is True assert form.fields['resolve_summary'].required is True assert form.fields['problem_cause'].required is False
def test_problem_details_error_messages(): form = forms.ProblemDetailsForm(data={}) assert len(form.errors) == 5 form.errors['product_service'] == [ 'Tell us what you’re trying to export or invest in' ] form.errors['location'] == [ 'Tell us where you are trying to export to or invest in' ] form.errors['problem_summary'] == [ 'Tell us about the problem you’re facing' ] form.errors['impact'] == [ 'Tell us how your business is being affected by the problem' ] form.errors['resolve_summary'] == [ ('Tell us what you’ve done to resolve your problem, ' 'even if this is your first step') ]
def test_problem_details_form_serialize(): form = forms.ProblemDetailsForm(data=problem_details_form_data()) assert form.is_valid() assert form.cleaned_data == problem_details_form_data()