Esempio n. 1
0
def test_search_required_empty_sector_term():
    form = forms.CompanySearchForm(data={'term': '', 'sectors': ''})

    assert form.is_valid() is False

    assert form.errors == {
        '__all__': [forms.CompanySearchForm.MESSAGE_MISSING_SECTOR_TERM]
    }
Esempio n. 2
0
def test_company_search_submitted_shows_filters():
    template_name = 'company-search-results-list.html'
    context = {
        'form': forms.CompanySearchForm(data={'term': 'things'}),
    }

    html = render_to_string(template_name, context)

    assert SEARCH_FILTERS_LABEL in html
Esempio n. 3
0
def test_company_search_unsubmitted_hides_filters():
    template_name = 'company-search-results-list.html'
    context = {
        'form': forms.CompanySearchForm(),
    }

    html = render_to_string(template_name, context)

    assert SEARCH_FILTERS_LABEL not in html
Esempio n. 4
0
def test_search_form():
    form = forms.CompanySearchForm(data={
        'term': '123',
        'sectors': ['AEROSPACE']
    })

    assert form.is_valid() is True
    assert form.cleaned_data['term'] == '123'
    assert form.cleaned_data['sectors'] == ['AEROSPACE']
Esempio n. 5
0
def test_company_search_shows_result_count(count, expected):

    paginator = Paginator(range(count), 10)
    pagination = paginator.page(1)

    template_name = 'company-search-results-list.html'
    context = {
        'form': forms.CompanySearchForm(data={'term': 'things'}),
        'pagination': pagination,
        'results': [default_context['company']] * count,
    }

    html = render_to_string(template_name, context)

    assert expected in html
Esempio n. 6
0
def test_search_required_fields():
    form = forms.CompanySearchForm()

    assert form.fields['sectors'].required is False
    assert form.fields['term'].required is False